Code cleanup. Adding javadoc.