Improve the error handling slightly.