Check in of an old chunk of code I have used, for posterity