fix some memory leaks.