Ken work v2

Here's an updated (openBSD fix) and rebased version of Ken's work.