Addressing memory leak