Some minor fixes to error handling code. More substantial improvements are needed long term.