plug some memory leaks