Added comments and javadoc