This looks quite good, I've changed a number of style issues but the only code I modified was to get rid of a goto in make_new_ds_set() and remove a small helper function that was only ever called from one place and which I thought just added a bit of unnecessary confusion. I'm going to call Tony's code "reviewed", but I'm putting the branch in the review queue so someone can make sure I didn't dork up those two changes. They're in commit 7a13d99989b.