Minor fixes for problems reported by valgrind

Two small patches for cleanup problems.