Added javadoc and cleared up a bit of the error reporting