Added javadoc and comments