             let enclosures = articles.reduce([Enclosure]()) { $0 + Array($1.enclosuresArray) }
 
             var totalRemaining = feeds.count + articles.count + enclosures.count
-            let semaphore = dispatch_semaphore_create(0)
+            let lock = NSRecursiveLock()
 
             let checkForCompleted = {
                 totalRemaining -= 1
                 if totalRemaining == 0 {
-                    dispatch_semaphore_signal(semaphore)
+                    lock.unlock()
                 }
             }
 

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

            dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER)
            finish()
        }
    }

                var articlesDictionary: [Article: Article] = [:]

                var totalRemaining = feedsToMigrate.count + articlesToMigrate.count + enclosuresToMigrate.count
                let lock = NSRecursiveLock()

                let checkForCompleted = {
                    totalRemaining -= 1
                    if totalRemaining == 0 {
                        lock.unlock()
                    }
                }

