Refactored the graphics manager to give control of the main loop to the main function. Finally removed the old state_machine.* files.