Dude, all these cleanups belong on a cleanup callback. There's no point on having them if they don't get called when the function fails.