Nikita, Please take a look at the attached patch. I have rewritten it a little, and only lightly tested it. Rich.