Some work on relations which work now on entity reference basis.

Documentation and some loose tests.