Fix homing code