Extracted queue.js plus small changes