clean up and add javadoc