Fixes bug in exception handling.