Fixed returned error codes