First end-to-end working DB version. Refactorings to come