Move header offset calculations to the block of code in which the pointers are known to be valid.