improve error reporting and recovery