More robust error handling.