Mostly working code and example