code cleanup and fix bug that sometimes prevented tab notifications from working