Window switching work, some more bug fixes