Use of `Ref` in broadcasting user-defined functions

You are using Ref in broadcasting correctly. Ref inhibits broadcasting from iterating over the fields of p.