Jamie,
thanks for posting about this as I hadn't seen it before! I think what you're doing is superb! If you submit the patch I volunteer to apply it tomorrow...
Since your code looks very readable and well designed I'm sure we can collectively weed out the remaining bugs in the proc.