Fixed some memory leaks. Still many more to go