Improved exception handling.