Redid the main event switch (without switches)

+ added window focusing handling