Fix some issues with exceptions