Fixed config and memory leakage