some changes to support multiple queues