esp4: Simplify the calculation of variables