In dev version (not changed for a while) it is doing this:
1. Go up
2. Store offsets if wanted
3. Go 5mm down
4. Home z
So the values stored are correct in any case. And after a homing without the issue the position is also correct. Not sure why you say 20mm as it should go down 5mm first. Only after homing sequence it will go down the 20mm you said. You could go into commands.cpp and search
<p class="p1">case 132:</p><p class="p1">and uncomment the home command at the end. Then it should only leave the 5mm down and it should be easier to spot when exactly the problem occurs. Of course you then need to home manually.</p>