Fix race condition in copyTree

Should fix #76