Fix bug in game loop.