Housekeeping

Did some cleaning, in particular made main.cpp much more manageable