Refactoring DB initialization

Issue #212