Added more comments and javadoc documentation