Polished jsdocs
changed error handling so that error codes are always passed down.