Fix for crashes caused by flushing the graphics context... What?