Support bounded queries

Fixes #2