Fixed the game loop; some parts were wrong or missing.