Clean up the gui code and working on the state_machine script.