Some refactoring, formatting, and javadoc fixes.