             }
         }
         
-        // Callback when all events have been applied
         fetchedRecordsController.didChange { [unowned self] in
+            // All events have been applied
+            print("AFTER \(self.fetchedRecordsController.fetchedRecords!.map { ["id":$0.id, "position":$0.position] })")
             self.tableView.endUpdates()
         }
+        
+        // TODO: fix crash
+        //
+        // When we remove the comparison function below, the controller only
+        // emits deletes and inserts.
+        //
+        // This should work just as well.
+        //
+        // But sometimes it crashes:
+        //
+        //      POSITIONS BEFORE [0, 4, 6, 7, 9, 12, 15, 16, 18, 19]
+        //      INSERTED AT index 0
+        //      INSERTED AT index 1
+        //      DELETED FROM index 0
+        //      INSERTED AT index 2
+        //      DELETED FROM index 1
+        //      INSERTED AT index 3
+        //      DELETED FROM index 2
+        //      INSERTED AT index 4
+        //      DELETED FROM index 3
+        //      INSERTED AT index 5
+        //      DELETED FROM index 4
+        //      INSERTED AT index 6
+        //      DELETED FROM index 5
+        //      INSERTED AT index 7
+        //      DELETED FROM index 6
+        //      INSERTED AT index 8
+        //      DELETED FROM index 8
+        //      DELETED FROM index 9
+        //      INSERTED AT index 10
+        //      DELETED FROM index 10
+        //      INSERTED AT index 11
+        //      POSITIONS AFTER [1, 2, 3, 6, 7, 10, 11, 13, 15, 17, 18, 19]
+        //      endUpdates(): crash
         
         // Compare two persons. Returns true if controller should emit a .Move or
         // .Update event instead of a deletion/insertion.

                self.tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
                
            case .Move(let indexPath, let newIndexPath, let changes):
                //            // technique 1
                //            tableView.deleteRowsAtIndexPaths([indexPath],
                //                withRowAnimation: UITableViewRowAnimation.Fade)
                //            tableView.insertRowsAtIndexPaths([newIndexPath],
                //                withRowAnimation: UITableViewRowAnimation.Fade)
                // technique 2
                let cell = self.tableView.cellForRowAtIndexPath(indexPath)
                self.tableView.moveRowAtIndexPath(indexPath, toIndexPath: newIndexPath)
                if !changes.isEmpty, let cell = cell {

        
        // The fetched objects
        let fetchRequest = Person.filter(Col.visible).order(Col.position, Col.firstName, Col.lastName)
        fetchedRecordsController = FetchedRecordsController(dbQueue, fetchRequest)
        
        fetchedRecordsController.willChange { [unowned self] in
            // Events are about to be applied
            print("-----------------------------------------------------------")
            print("BEFORE \(self.fetchedRecordsController.fetchedRecords!.map { ["id":$0.id, "position":$0.position] })")
            self.tableView.beginUpdates()
        }
        
        fetchedRecordsController.onEvent { [unowned self] (person, event) in
            // Apply individual event
            print(event)
            switch event {
            case .Insertion(let indexPath):
                self.tableView.insertRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
