Added javadoc and error messages