         guard let completions: [ImageStoreCompletionHandler] = completionsByURLString[url.absoluteString] else {
             return
         }
-        if let _ = downloadTaskByURLString[url.absoluteString] {
-            downloadTaskByURLString.removeValue(forKey: url.absoluteString)
+        if let _ = getDownloadTask(for: url) {
+            removeDownloadTask(for: url)
         }
         DispatchQueue.main.async { [weak self] in
             completions.forEach { $0(nil, .taskError(error)) }

            let data = try Data(contentsOf: location)
            if let image = UIImage(data: data), let url = downloadTask.currentRequest?.url {
                cache.setObject(image, forKey: url.absoluteString as AnyObject, cost: data.count)
                if let _ = downloadTaskByURLString[url.absoluteString] {
                    downloadTaskByURLString.removeValue(forKey: url.absoluteString)
                }
                guard let completions: [ImageStoreCompletionHandler] = completionsByURLString[url.absoluteString] else {
                    return

    public typealias ImageStoreCompletionHandler = ((UIImage?, ImageStoreError?) -> Void)

    private(set) public static var shared: ImageStore = ImageStore(ImageStoreConfig())
    private let ioQueue = DispatchQueue(label: "ImageStore_Serial_Queue")

    public class func reset(config: ImageStoreConfig = ImageStoreConfig()) {
        shared = ImageStore(config)
