RFR: Refactor code to support arbitrary rollups

Feedback welcome!