Improved error code handling.