Further improved error handling