Fixed a race condition.