Rearrange code to let newly opened tab to be shown a bit earlier