Added java docs, modified code