Merge Ron's code; cleanup

I merged Ron's code into a separate branch, verified it works, and then made a bunch of minor changes per pylint and flake8 output.