Code cleanup in scheduler