Fixed a couple of bugs identified while throwing exceptions