Fix up offset calculations