Seems complete now (totally untested), plus added a figure