First approach towards the simplification of refs.

`Ref` has been moved to another file, so now, the core module does not
contain references to `Ref`. However, there are still some lines which
are difficult to reason about. For instance, does it make sense to
have the type constructor `ref` as part of the program? Probably not,
but this has to be further analised before making a decision.