Replaced db_query with db_select for cancellations
Replaced db_query with db_select for queue