Fixed a couple of memory leaks & warnings