                     }
                 }
 
-                dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER)
+                lock.lock()
                 finish()
             }
         }

            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)
                }
            }


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

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

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

