Fixed ordering bugs in the scheduler

Queue was sorting out of order, and added an index to ensure determenistic first
in/first out