Performance optimization of genealogy code.