         }
     }
 }
+
+// MARK: - Debug
+
+#if DEBUG
+
+func DEBUG_LOG(format: String, args: CVarArgType...) {
+    withVaList(args) { NSLogv(format, $0) }
+}
+
+#else
+
+func DEBUG_LOG(format: String, args: CVarArgType...) {
+    withVaList(args) { NSLogv(format, $0) }
+}
+
+#endif // DEBUG

        var requestCompleted = false
        let completionHandler: CompletionHandler = { (content: [String: AnyObject]?, error: NSError?) in
            requestCompleted = true
            
            // Remove request from list of pending requests.
            // Also cancel and remove all previous requests (as this one is deemed more recent).
            if let index = self.pendingRequests.indexOf(operation) {
                for i in 0..<index {
                    self.pendingRequests[i].cancel()
                }
                self.pendingRequests.removeRange(0...index)

            let queryHelper = QueryHelper(query: query)
            operation = index.searchDisjunctiveFaceting(query, disjunctiveFacets: state.disjunctiveFacets, refinements: queryHelper.buildFacetRefinementsForDisjunctiveFaceting(), completionHandler: completionHandler)
        }
        operation.name = "\(index) #\(state.sequenceNumber): \(query)"
        self.pendingRequests.append(operation)
        DEBUG_LOG("START \(operation.name!)")
        
        // Schedule a task to check if the request is slow.
        if let threshold = slowRequestThreshold {
