added some javadoc and comments