fixed a couple potential memory leaks