Fix for ref with #undefs. Fixes #199, partially addresses #198,
and (I think) fixes #171. I only updated ref for DataVectors. Higher
dimensions will have to wait for a closer look. I'm not sure this is
the right way.