Fixes to report better errors, avoid catastrophic failures