improvments on queue, adding max queue, adding mutex for queue counter