added tests for scheduler and minor optimizations