Initial implementation of new-style refs

cf. #1373

This implementation can be used in any situation that refs can currently be used (and can also be used without an owner, which is a plus).