Final touch includes more javadoc, refactoring and test.