Remove unused variables, also clear orphans when file is deleted.