Merge "Clean the code in ref frame context decision for ext-refs" into nextgenv2