Fixed bugs introduced in last few days.

Also added a couple more aggregation cases.