This code mostly works, but is obviously not complete. This commit just adds the code and tests, but does not enable it in OID or OIL.