Fix common exception handling gotchas.