Capped collections code refactoring