NOTE: see z for a simpler and lighter version. See docs and sample implementations in examples directory.