Fixed bug in memory leak fixing