refactoring, code cleanup, javadoc, and dead code removal