         guard let url = episode.audioURL, let downloadInfo = episode.downloadInfo,
             let resumeData = downloadInfo.resumeData else { return }
         let task = session.downloadTask(withResumeData: resumeData)
-        downloadedUrls[url] = task
+        downloadedUrls[task] = url
         downloadInfo.setValue(task.taskIdentifier, forKey: DownloadInfo.Keys.identifier)
         saveData()
         task.resume()

            let url = episode.audioURL else { return }

        let task = session.downloadTask(with: url)
        downloadedUrls[url] = task
        let downloadInfo = NSManagedObject(entity: entity, insertInto: appDelegate.dataController.managedObjectContext)
        downloadInfo.setValuesForKeys([
            DownloadInfo.Keys.progress: 0,

        return URLSession(configuration: configuration, delegate: self, delegateQueue: OperationQueue())
    }

    /// Maps task handling the download to the download task
    private var downloadedUrls: [URLSessionDownloadTask: URL] = [:]

    func download(episode: EpisodeMO) {
        guard let appDelegate = UIApplication.shared.delegate as? AppDelegate,
