RexMatch refactoring and bug fix.