Added support for multiple queues, and ensured queue management is locked