Fixed tabState reseting bug
Refactored popup
Fixed undefined bug