Improved exception catching.