All aggregate functions working now.
Next is code cleanup and testing.