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.
I did at first, but since this method is not called very often it should not make much of a difference. I didn't want to clutter the class with extraneous variables.