Preliminary aggregation update

Fixing json aggregation for new database structure.

Still a couple of kinks to work out.