Fix offset calculations.