fix scripts & memory leakage