Database connection refactor.