fixed internal variable freeing
added valgrind config file
Merge branch 'fix-memleak'