Initial centralization of DB code. Issue #1.