Made events guaranteed to unbind correctly in dialog