This fixes a bunch of little things, including switch tabs between windows with different states (closing PR 12341) and switching to a non-module language.