Array offset calculations are wrong.