minor cleanup, documentation, and refactoring