memory leak fixes

I fixed some memory leaks.