Solve memory leak