I've included all of the code from #404 here so I'll close the other one.