fixed realm handling to reflect recent discussions with Brian