Disappearing event bugg-fix
The bugg was caused by the global var.
The fix makes sure that the global var only holds an reference to a
element of correct type.