Fixed cleanup and free

Error was with selecting right node
Goes along with previous commit