Fix some smaller leaks from valgrind log from #452 (closed). See commit description for more details.