Fixes to globals and window flicker