Refactor AutoQuery impl into logical chunks