improved memory leaking issue