Working on #726: Valgrind

Adding basic valgrind support