loose ends and a glaring lack of documentation, but it basically works. Simon Riggs with some editorialization by Tom Lane.