Eluna do changes to make things similar to TC code
Eluna fix memory leak