make buffer size a power of 2 and optimize buffer lookup

Yields 10-25% faster aggregations for timeseries queries, depending on the number of aggregators.
Can these be moved to class final variables?