Fix window crashing