Misc cleanup

Mostly JavaDoc, whitespace, and minor refactoring.