Fixed a bug with exception handling.