Add realm support

/to @ritch 
/cc @bajtos @dashby3000