Changes to handle new database structure.