Added a few checks for query counts