Restructured game loop
Merged