                 var articlesDictionary: [Article: Article] = [:]
 
                 var totalRemaining = feedsToMigrate.count + articlesToMigrate.count + enclosuresToMigrate.count
-                let semaphore = dispatch_semaphore_create(0)
+                let lock = NSRecursiveLock()
 
                 let checkForCompleted = {
                     totalRemaining -= 1
                     if totalRemaining == 0 {
-                        dispatch_semaphore_signal(semaphore)
+                        lock.unlock()
                     }
                 }
 

            let enclosures = articles.reduce([Enclosure]()) { $0 + Array($1.enclosuresArray) }

            var totalRemaining = feeds.count + articles.count + enclosures.count
            let semaphore = dispatch_semaphore_create(0)

            let checkForCompleted = {
                totalRemaining -= 1
                if totalRemaining == 0 {
                    dispatch_semaphore_signal(semaphore)
                }
            }


                database.deleteEnclosure($0, callback: checkForCompleted)
            }

            lock.lock()
            finish()
        }
    }
