Fix active window bug