Fix small memory leaks

Mostly to make valgrind happy