fixed some mem leakage