Refactoring GameMain. Things still might be broken.