patch some memory leaks.