Refactor main

Restructure and refactor main.cpp (in particular main() itself)

Spaces here. Sorry for being picky. Probably doesn't matter, this is good code compared to the majority of the engine. :S