Some refactoring and javadoc comments.