fix performance problems when switching windows