Added failsafe for automated arm movement. Code cleanup