Fixed bug in exception handling.