some memory leak fixes in idf