Made adding a save event to the event store asynchronous.
It was possible to get a deadlock if a save and merge are happening at the same time, because creating the save event occurred in a performBlockAndWait:. If the merge creating needed to callback to the main thread, which seems to occur when the event store gets saved, it would cause a deadlock.
The fix is to make creation of the save event asynchronous, using performBlock: instead.
The downside is that you need to be sure that the event store is fully saved when terminating. You can use processPendingChanges or just do a merge, which also ensures the event store is saved.