Fixed memory leak bug