Refactoring and javadoc a little