introduced queues and fixed some other issues