Clarify use of `ref` attribute and fix examples.

Related to #804.