Added a sanity check in branchVariables()