Fixed some memory leaks