Add more error codes, messages and error checking.