avoid memory leaks.
Using valgrind and osx leaks command.