added needClear flag to take care of initial window clear and window resize clears