Reworked database structure. Needs rework of remaining code