Improve error handling.