Support count(*) better + misc cleanup.