A. Klocker's original code
P. Barker's modifications as of March 8th, 2013. I modified the copyright statement corrispondingly.