Added javadocs + minor code changes