Added handler for onReplaced event, which is the proper way of handling the bug where tab id changes.