Refactoring of database connection code.