Fix reference id when moving subtree