SegmentedQueue refactoring