Fix some memory leaks and uninitialized memory use

Valgrind and Splint picked up on some pretty big memory leaks. Hanging
my head in shame that I didn't pick up on some of these :-P