Miscellaneous refactoring, documentation, and clean-up.
A few more edits.