added javadoc and fixed formatting issues