post-tree-replace bug fix