Abstracted some of the copy_tree stuff out