fixes to exception handling