Fix valgrind warnings in testing branch

Sorry about the deluge of pull requests.  This one fixes some valgrind warnings new to the testing branch.