Final changes and added javadoc.