Refactored some of the internal logic in collection classes.