Citations fix AND JSON error fix for newer postgres

the citations code was easy.  the JSON fix took all day!