Refactored pq.js to remove js issues