Valgrind fixes + fix example