move database-interaction into own local library.
prevent garbage time values through defaults.
Merge branch 'sanity_refactoring'