changed db structure + optimisations