Minor code cleanup and adds javadoc.