Added comments and a check in the tab listener.