Made the main game loop more generic