fix a few minor memory leaks