Tidied up the main program and the game engine a bit