Fixing ref list memory leaking