Finished refactoring and javadoc comments.