added some comments and javadocs