Move pending reference handing to separate thread, and use NSPersistentStore metadata (fixes #62)