Fix some memory leaks bug.