Improving performance by changing queueIndex for the constraints and simple tuning.