Yay! Great news :) I'm not in envy of poor coder, it doesn't seem like a gentle thing to do (as far as I can speculate).
Unfortunately, it appears to be a wicked problem. Note that I'm using 'wicked problem' in the technical sense, meaning it's a very large can of flying, venomous, and downright pissed off shai-hulud. @-V- is going to need a lot of adult beverages when he gets that working!