Fixes to sendresponse for easier chaining. Added countByQuery.