private StringBuffer rebuildFactionProperties(Faction F)
	{
		List<String> oldV=Resources.getFileLineVector(Resources.getFileResource(makeFactionFilename(F.factionID()),true));
		if(oldV.size()<10)
		{
			final StringBuffer template=new CMFile(Resources.buildResourcePath("examples")+"factiontemplate.ini",null,CMFile.FLAG_LOGERRORS).text();
			oldV=Resources.getFileLineVector(template);
		}
		final boolean[] defined=new boolean[Faction.TAG_NAMES.length];
		for(int i=0;i<defined.length;i++) 
			defined[i]=false;
		for(int v=0;v<oldV.size();v++)
		{
			final String s=oldV.get(v);
			if(!(s.trim().startsWith("#")||s.trim().length()==0||(s.indexOf('=')<0)))
			{
				final String tag=s.substring(0,s.indexOf('=')).trim().toUpperCase();
				final int tagRef=CMLib.factions().isFactionTag(tag);
				if(tagRef>=0)
					defined[tagRef]=true;
			}
		}
		final boolean[] done=new boolean[Faction.TAG_NAMES.length];
		for(int i=0;i<done.length;i++) done[i]=false;
		int lastCommented=-1;
		final String CR="\r\n";
		final StringBuffer buf=new StringBuffer("");
		for(int v=0;v<oldV.size();v++)
		{
			String s=oldV.get(v);
			if(s.trim().length()==0)
			{
				if((lastCommented>=0)&&(!done[lastCommented]))
				{
					done[lastCommented]=true;
					buf.append(F.getINIDef(Faction.TAG_NAMES[lastCommented],CR)+CR);
					lastCommented=-1;
				}
			}
			else
			if(s.trim().startsWith("#")||(s.indexOf('=')<0))
			{
				buf.append(s+CR);
				final int x=s.indexOf('=');
				if(x>=0)
				{
					s=s.substring(0,x).trim();
					int first=s.length()-1;
					for(;first>=0;first--)
					{
						if(!Character.isLetterOrDigit(s.charAt(first)))
							break;
					}
					first=CMLib.factions().isFactionTag(s.substring(first).trim().toUpperCase());
					if(first>=0)
						lastCommented=first;
				}
			}
			else
			{
				final String tag=s.substring(0,s.indexOf('=')).trim().toUpperCase();
				final int tagRef=CMLib.factions().isFactionTag(tag);
				if(tagRef<0)
					buf.append(s+CR);
				else
				if(!done[tagRef])
				{
					done[tagRef]=true;
					buf.append(F.getINIDef(tag,CR)+CR);
				}
			}
		}
		if((lastCommented>=0)&&(!done[lastCommented]))
			buf.append(F.getINIDef(Faction.TAG_NAMES[lastCommented],CR)+CR);
		return buf;
	}