fix a bug in the calculation of the explicit offset. Use the opportunity to
clean up the code a bit.