Database connection logic refactor. Database reset script.