refactoring and auto delete old jobs