refactoring and more java docs