Refactor main

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

add space before (