fixing futher memory leaks