Error Check / Documentation

Added more validation code and some additional comments as well as basic javadoc.