Initial support for ref() in valid/invalid. For #260