added javadoc and minor improvements