ported all necessary functionality for TimeseriesAggregateImplementation. TODO: Code cleanup