Check for $ref['_elem'] before using it.

I was getting notices about `'_elem'` not being defined for some entries in `$event->data->_content`.  This checks for it first, and stops `$ref['_tag']` and `$ref['class']` from being looked at too.

(By the way, I like the work that's been done in the multiple_users branch!  I'm using it.)