Fixes to main game loop and other debuggings