public int processAllUnused(final boolean preserve)
	{
		int result = 0, removed = this.processUnused(preserve);
		String verb = preserve? "Unused " : "Removed ";
		if(removed > 0)
		{
			System.out.println(verb + removed + " in global scope");
		}
		List<String> toRemove = new ArrayList<String>();
		Iterator<String> it = templates.keySet().iterator();
		while(it.hasNext())
		{
			String nextName = it.next();
			Scope scope = templates.get(nextName);
			//checking 'dontRenameParams' is a bit of a hack but it is faster than looking up the match attribute again
			if(!scope.dontRenameParams && !scope.hasReferences())
			{
				//if we are in here then "scope" is a template with no match attribute (and no references), therefore it MUST have a name
				toRemove.add(nextName);
			}
			else
			{
				removed = scope.processUnused(preserve);
				if(removed > 0)
				{
					result += removed;
					System.out.println(verb + removed + " in " + nextName);
				}

			}
		}
		for(String nextName : toRemove)
		{
			if(!preserve)
			{
				Scope.removeNode(nextName, templates);
			}

			System.out.println(verb + " template: " + nextName);
		}
		return result + toRemove.size();
	}