fixed some memory leaks- but not all.