Refined error handling.