         // thus completion will fire **after** synchronize unblocks
         let mainQueueCompletion : (success: Bool) -> () = {
             (success: Bool) -> () in
-            dispatch_async(dispatch_get_main_queue(), { () -> Void in
+            if NSThread.isMainThread() == false {
+                dispatch_async(dispatch_get_main_queue(), { () -> Void in
+                    completion?(success: success)
+                })
+            }
+            else {
                 completion?(success: success)
-            })
+            }
         }
         
         _getCachedData (completion: {(data) -> () in

public class FeedCache<T:FeedItem>{
    
    let name: String!
    let diskOperationQueue = NSOperationQueue()
    public var items : [T] = []
    public var saved = false
    
    public init(name: String) {
        diskOperationQueue.maxConcurrentOperationCount = 1
        self.name = name
    }

    
    // Wait until operation queue is empty
    public func waitUntilSynchronized(){
        if diskOperationQueue != NSOperationQueue.mainQueue() {
            diskOperationQueue.waitUntilAllOperationsAreFinished()
        }
    }
    
    private func _deleteCache() {
