Clean-up in QueryImpl