Optimizing game loop