Fix #171: rework query clone to avoid spurious copy of dataset

Fixes #171.