change cleanTermini to work on sorted files.