Add delete old files behaviour and fixed some unused imports