Some memory leak fixes.