fixed various issues in scheduler and apply