   func toTripRequest() -> TripRequest
 }
 
+fileprivate extension TKRouterRequestable {
+  func perform(_ block: @escaping (Self) -> Void) {
+    if let context = context {
+      context.perform {
+        block(self)
+      }
+    } else {
+      block(self)
+    }
+  }
+  
+  func performAndWait<R>(_ block: (Self) throws -> R) throws -> R {
+    if let context = context {
+      var result: R! = nil
+      var blockError: Error? = nil
+      context.performAndWait {
+        do {
+          result = try block(self)
+        } catch {
+          blockError = error
+        }
+      }
+      if let blockError = blockError {
+        throw blockError
+      } else {
+        return result
+      }
+    } else {
+      return try block(self)
+    }
+  }
+}
+
 extension TKRouter.RoutingQuery: TKRouterRequestable {
   public func toTripRequest() -> TripRequest {
     guard let context = context else { preconditionFailure() }

    
    if workers.isEmpty {
      // Only show an error if we found nothing
      request.context?.perform {
        if request.trips.isEmpty, let error = self.lastWorkerError {
          completion(.failure(error))
        } else {

    self.workerQueue = queue
    var count: UInt = 0
    queue.sync {
      do {
        count = try self.multiFetchTripsWorker(request: request, modes: modes, classifier: classifier, progress: progress, on: queue, completion: completion)
      } catch {
        self.handleError(error, callbackQueue: queue, completion: completion)
      }
    }
    return count
  }
    
  private func multiFetchTripsWorker(request: TKRouterRequestable, modes: Set<String>? = nil, classifier: TKTripClassifier? = nil, progress: ((UInt) -> Void)? = nil, on queue: DispatchQueue, completion: @escaping (Result<TripRequest, Error>) -> Void) throws -> UInt {
    
    let includesAllModes = try request.performAndWait { $0.additional.contains { $0.name == "allModes" } }
    
    if includesAllModes {
      modeIdentifiers = try modes ?? request.performAndWait(\.modes)
      fetchTrips(for: request, bestOnly: false, additional: nil, callbackQueue: queue, completion: completion)
      return 1
    }
    
    let enabledModes = try modes ?? request.performAndWait(\.modes)
    guard !enabledModes.isEmpty else {
      throw RoutingError.invalidRequest("No modes enabled")
    }
    
    let groupedIdentifier = TKTransportModes.groupModeIdentifiers(enabledModes, includeGroupForAll: true)
    
    let tripRequest: TripRequest = try request.performAndWait {
      let tripRequest = $0.toTripRequest()
      try request.context?.save()
      return tripRequest
    }
    
    let additional = try request.performAndWait(\.additional)
    
    queue.async {
      self.cancelRequestsWorker()
