Query interface #18

just for review, please don't merge yet.