More memory leak fixes