Misc. exception handling cleanup--moved it out of global function namespace