Performance improvements to the "bag" object.