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

Does not yet compile.

See ticket 391.