Make our checks for definitions a bit more explicit.

The previous if $realm syntax might've checked for
definition or might have made a boolean check.  Comparing
to undef more clearly expresses what we actually care about.

I've also added explicit :: scope indicators for good measure.

Change-Id: I37b49ae98c28b63698200608d4621ae157c3fbe2