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

Does not yet compile.

See ticket 391.