Improve exception handling code.