Mostly improvements to error handling.