removed some of the memory leaks