Minor code alterations. Added javadoc.