@Phaedrux Wow this is working! I added this before the Z homing lines and everything work properly.
I also added the switch back to initial mapping at the end (so I don't do this trick to the homey.g also)
; homeall.g
; called to home all axes
;
G91 ; relative positioning
G1 H2 Z5 F6000 ; lift Z relative to current position
G1 H1 X-480 Y-480 F3000 ; move quickly to X and Y axis endstops and stop there (first pass)
G1 H2 X5 Y5 F6000 ; go back a few mm
G1 H1 X-480 Y-480 F360 ; move slowly to X and Y axis endstops once more (second pass)
G90
G0 X-40 Y5
G91
M574 Y1 S1 P"nil"
M574 Z1 S1 P"ystop+e1stop"
G1 H1 Z-405 F360 ; move Z down stopping at the endstop
G90 ; absolute positioning
G92 Z-2.4 ; Adjust Z offset
G1 Z20
M574 Z1 S1 P"nil"
M574 Y1 S1 P"ystop+e1stop"
Thank you Jay and Phaedrux for your help.
A.