based on work of Raymond E. Pasco <ray at ameretat dot dev> and abieber@ using feedback from <trondd at kagu-tsuchi dot com> and sthen@; OK sthen@