Fixed a couple of memory leaks