Fixed some bugs caused by exiting the game

To do - save game state