Added cycle detection, cleaned up game.c