Updating the database queries, etc

Due to the new database model, the database queries were changed.