fix session memory leaks