Improve exception handling.