refactor main.py, flesh out functions from main function

@stdweird, @wpoely86: please review?

The diff is going to look a bit messy, maybe you want to look at the actual new `main.py` instead...
this is horrible. make a list of all options where key is the attr, and generate that part via a loop. this is too error prone to ever review. sorry