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

Does not yet compile.

See ticket 391.