Memory management improvements in LinkedBag