Added javadoc and a bit of comments in the code