Solved the memory leak.