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 see and inspect the differences. (I'm not really what best practices are in this regard, so I guess we can set a precedent.)