Improve the UUID conversion routine (see #6481)