This is a try of pruning the memory leaks in the insertion process