Various fixes, and support for 2012 aggregate functions.