Improve exception management