Fix scheduler bug and improve a few functions