Changed the delete logic due to issues with running managed_directory :clean delayed