Now returns proper error codes