We have a lot of duplicated code that is initializing, copying and passing around a set of time pairs and aggregated time pairs.
We should abstract those out into data structures and helper functions to clean up the code and minimize the chance of copy-paste errors.