Add some javadoc, clean up a little code