Compound queries

Implements #65