Fixed some memory leaks.