little changes to backreference production

I made some changes in the way backreferences are produced. This way only the backreferencs of the matching rule is taken into account.