Fixed more bugs in the game logic function. Also added some more log statements to it.