Improve database management
Update queries with new db architecture