Basic DB setup; code structure refactoring