Code cleanup and Javadoc.