Fix broken exception handling