Fix some race conditions in the token image manager code.