Oops! Synchronize access to paintNeeded.
Minor tidying.