     func loadJSON(urlRequest: URLRequest,
                   completion: @escaping (JSONDictionary?, WikipediaError?) -> ())
         -> URLSessionDataTask {
-        
+
+        let startTime: Date
         #if DEBUG
-            let startTime = NSDate()
-            print("WikipediaKit: Fetching \(urlRequest.url!.absoluteString)")
+            startTime = Date()
+            self.logMessage("Fetching \(urlRequest.url!.absoluteString)")
         #endif
         
         var urlRequest = urlRequest

            #if DEBUG
                let endTime = NSDate()
                let totalTime = endTime.timeIntervalSince(startTime as Date)
                print("WikipediaKit: \(totalTime) seconds for network retrieval & JSON decoding")
            #endif
            
            completion(jsonDictionary, nil)

        return WikipediaNetworking()
    }()

    public var debugPerformance = false

    private func logMessage(_ message: String) {
        #if DEBUG
        if self.debugPerformance {
            print("WikipediaKit: \(message)")
        }
        #endif
    }

    public static weak var sharedActivityIndicatorDelegate: WikipediaNetworkingActivityDelegate?
    
    let session = URLSession(configuration: URLSessionConfiguration.default)
