Fixed crash when a window left fullscreen.
Some more optimizations.