Fix race condition in copyTree

Should fix #76
Merge pull request #104 from kriskowal/gh-76-v1

Fix race condition in copyTree