More extensive error handling.