Fix memory leak problem