Fix countqueries script for incorrect or missing URIs