Reference implementation (POC) for #181. Still has a couple bugs :)