Further improvements to error handling.