Fixed a potential concurrent modification problem.