Fix error codes handling