clean up the source code, add missing javadocs