Fix memory leak issue