Treefunction failing with randomly phased data