Added tests to capture nondeterminism. Improved the aggregator's flex selection algorithm.