Fixed "undefined variable"
Fixed duplicate items in queue