adding java docs and refactoring some methods