Merge pull request #360 from xiulipan/schfix2

Fix for scheduler bugs