Refactor main

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

Indentation :P