done some refactoring and more java docs