Dim inactive tabs.
Stop updating inactive tabs.
Take over main event loop.
Move the replace operation to after the event.
Don't automatically switch to the new tab everytime.