Rework storage of anything backed by a database (to be completed, intermediate results still work fine)