Changed Ref.isDirty() to check refRec.isDirty().