Added a bit of maintenance to the game loop.