Merge work on main program into master

I think it is time to merge my work on the main program into master. @kboyd, what do you think?

I can merge master into dev/afbarnard first if that would help you see and inspect the differences. (I'm not really sure what best practices are in this regard, so I guess we can set a precedent.)

This will close #12.