Fixed a couple of 'usage after free' bugs