fix memory leak in scheduler