Fixed some bugs in the game logic.