Minor memory leak fixes