Review and changes from Jocelyn Fiat

we could remove that function set_realm