Minor refactoring, partially document main.py
Merge branch 'Ben-refactoring'