Updated scheduling code.