Fixed some gaping memory leaks