cleaned code and added endstop and axis homing functions