Fixed game loop timing and restructured