Optimizations of game loop and drawing