Fix some bags in exception handling.