Added a mostly working implementation.