Refactor queue
Add more comments