Improve lineage function