Fix backtracking ref bug