Memory leak issue, implemented some diagnostic tools