Clean up code and documentation

This commit includes minor improvements to numerous files, but not all
code has yet been reviewed for basic style and documentation issues.