Bug fix for race condition.