move all functionality into QueryBatches module