Fixed up querying so count works etc.