fix some memory leakage