Make tree version numbers more robust