Core: refactor storage layer, pt.6 (#389, #391).

Introduce association index.
Does not yet compile.

See ticket 389.
See ticket 391.