Right, a few dozen pages later, I've got some progress. http://pastebin.com/WivzJan8