Improve error recognition and handling.