             let time = NSDate(timeIntervalSinceNow: interval)
             fetchRequest.predicate = NSPredicate(format: "plotTime < %@", time)
 
+            let request = NSBatchDeleteRequest(fetchRequest: fetchRequest)
+            request.resultType = .ResultTypeCount
             do {
-                let result = try childContext.executeFetchRequest(fetchRequest) as! [NSManagedObject]
-
-                for object in result {
-                    childContext.deleteObject(object)
-                }
+                let result = try childContext.executeRequest(request) as! NSBatchDeleteResult
+                DLOG("Deleted \(result.result!) plots")
 
                 try childContext.save()
 
                 childContext.processPendingChanges()
 
-                if let moc = self.managedObjectContext {
-                    moc.performBlock {
-                        do {
-                            try moc.save()
-                            moc.processPendingChanges()
-                            completionHandler?()
-                        } catch {
-                            DLOG("Save failed: \(error)")
-                            completionHandler?()
-                        }
+                self.managedObjectContext.performBlock {
+                    do {
+                        try self.managedObjectContext.save()
+                        self.managedObjectContext.processPendingChanges()
+                        completionHandler?()
+                    } catch {
+                        DLOG("Save failed: \(error)")
+                        completionHandler?()
                     }
                 }
             } catch {

        }

        dispatch_once(&Static.onceToken) {
            Static.instance = self()
        }

        return Static.instance!
    }

    public required init() {

        NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("mainManagedObjectContextDidSave:"), name: NSManagedObjectContextDidSaveNotification, object: managedObjectContext)
    }


    func mainManagedObjectContextDidSave(notification: NSNotification) -> Void {
        DLOG("Saving MOC based on notification")
        managedObjectContext?.mergeChangesFromContextDidSaveNotification(notification)
    }


    public func saveContext () {
        if let moc = self.managedObjectContext where moc.hasChanges {
            do {
                try moc.save()
            } catch let error as NSError {
                NSLog("Unresolved error \(error), \(error.userInfo)")
                abort()

    }


    public func removeStaleStationsFromWatch( stations: [Int], inManagedObjectContext managedObjectContext: NSManagedObjectContext) -> Void {
        let fetchRequest = NSFetchRequest(entityName: "CDStation")
        fetchRequest.predicate = NSPredicate(format: "NOT stationId IN (%@)", stations)

        let request = NSBatchDeleteRequest(fetchRequest: fetchRequest)
        request.resultType = .ResultTypeCount

        do {
            let result = try managedObjectContext.executeRequest(request) as! NSBatchDeleteResult
            DLOG("Deleted \(result.result!) station(s)")
        } catch {
            DLOG("Delete failed: \(error)")
        }
    }


    #if os(iOS)
    public func indexActiveStations() -> Void {
        let stations = CDStation.visibleStationsInManagedObjectContext(Datamanager.sharedManager().managedObjectContext)
        var items = [CSSearchableItem]()

        for station in stations {
            let search = CSSearchableItemAttributeSet(itemContentType: kUTTypeContent as String)
            search.city = station.city
            search.latitude = station.coordinateLat
            search.longitude = station.coordinateLon
            search.namedLocation = station.city
            search.displayName = station.stationName
            search.copyright = station.copyright
            search.keywords = ["kite", "surf", "wind", "fluid", "naish", "ozone", "f-one"]
            search.title = station.stationName
            search.contentDescription = station.city

            let url = "vindsiden://station/\(station.stationId!)"
            let item = CSSearchableItem(uniqueIdentifier: url, domainIdentifier: AppConfig.Bundle.appName, attributeSet: search)
            items.append(item)
        }

        let index = CSSearchableIndex()
        index.beginIndexBatch()

        index.deleteAllSearchableItemsWithCompletionHandler { (error: NSError?) -> Void in
            DLOG("Removed all indexed entries: \(error?.localizedDescription)")

            if items.count > 0 {
                CSSearchableIndex.defaultSearchableIndex().indexSearchableItems(items, completionHandler: { (error: NSError?) -> Void in
                    DLOG("Index completed: \(error?.localizedDescription)")
                })
            }
        }

        index.endIndexBatchWithClientState(NSData()) { (error: NSError?) -> Void in
            DLOG("Index completed: \(error?.localizedDescription)")
        }
    }
    #endif


    lazy public var managedObjectContext: NSManagedObjectContext = {
        let coordinator = self.persistentStoreCoordinator
        var managedObjectContext = NSManagedObjectContext(concurrencyType: .MainQueueConcurrencyType)
        managedObjectContext.persistentStoreCoordinator = coordinator
        managedObjectContext.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy

        return managedObjectContext
        }()


    lazy var managedObjectModel: NSManagedObjectModel = {
        let modelURL = NSBundle(identifier: AppConfig.Bundle.frameworkBundleIdentifier)?.URLForResource(AppConfig.CoreData.datamodelName, withExtension: "momd")
        return NSManagedObjectModel(contentsOfURL: modelURL!)!
        }()



    lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator = {
        let coordinator = NSPersistentStoreCoordinator(managedObjectModel: self.managedObjectModel)
        let url = self.applicationDocumentsDirectory.URLByAppendingPathComponent(AppConfig.CoreData.sqliteName)

        self.addSkipBackupAttributeToItemAtURL(url)

        var failureReason = "There was an error creating or loading the application's saved data."
        do {
            try coordinator.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: url, options: nil ) //[NSMigratePersistentStoresAutomaticallyOption: true, NSInferMappingModelAutomaticallyOption: true])
        } catch {
            // Report any error we got.
            var dict = [String: AnyObject]()
            dict[NSLocalizedDescriptionKey] = "Failed to initialize the application's saved data"
            dict[NSLocalizedFailureReasonErrorKey] = failureReason

            dict[NSUnderlyingErrorKey] = error as NSError
            let wrappedError = NSError(domain: AppConfig.Bundle.appName, code: 9999, userInfo: dict)
            // Replace this with code to handle the error appropriately.
            // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
            NSLog("Unresolved error \(wrappedError), \(wrappedError.userInfo)")
            abort()
        }

        return coordinator
        }()


    var applicationDocumentsDirectory: NSURL {
        let url = NSFileManager.defaultManager().containerURLForSecurityApplicationGroupIdentifier(AppConfig.ApplicationGroups.primary)
