Moved new database code throughout the repository