Fixed race condition closes #1715