Fix several reported memory leaks