fixed a couple of memory leaks