made a few small improvements to Realm usage