These checks are redundant, but I copied what `references` does.