Add support for count queries

Addresses issue #53