Added javadoc and some comments