Added some javadoc and a few small changes