Moved DB related stuff to its own module