Added code from Josquin.