fixed memory leaks. added valgrind support