Add more error codes, messages and error checking.

Same for this one