Tidy come comment formatting.
First major pass at refactoring main to isolate behaviours.