Merge in changes from Ivan's old repo

@ivmarkov -> Here are your commits from your old repo.

Want to double check that nothing is missing?  I had a couple merge conflicts, so it would be nice if you had a chance to make sure everything is as expected.

Feel free to hit the merge button at will...  ...This will hopefully be the last big refactoring, right?