updated to consider tab events
merged recent tab change/close event modifications