Fixed memory leaks
Fixed memory leak patch