Refactoring and javadocs