Fix memory leaks in phylogeny code