Assorted memleak fixes. Found on Michael Stefaniuc smatch list.