Various fixes for alt tab switcher
A bunch of fixes for bugs I found while implementing app opening and closing support for the alt tab switcher. Please have a good look at 9f4ce650, I'm not sure if it always works.
Some more bugs will get fixed with the new feature since they require bigger changes.