I think it would be an improvement to randomportraits for the randomizer to skip the existing portait file, so that it always generates a new image for an existing character. Perhaps that could be put into the next version. I think this line of code will do it.
# Filter on Race
var filteringPortraits = []
for p in validPortraits:
if p.file == person.imageportait: continue #Leo always find a different portrait
if p.races.has(person.race):
filteringPortraits.append(p)