improved fatal error handling