I feel like this code has changed since I last touched it.  What you're doing seems to make sense, I just can't recall the details to offer any advice, if I had it... :)