Fix Realm crashes