So that I don't forget how it works :)
This produces much more visually pleasing palettes compared to the crude algorithm which was previously used.