private void resetBorders()
	{
		mBorders.clear();
		final int size = getWidth() * getHeight();
		for (int tile = 0; tile < size; tile++ )
			mBorders.put(tile, createConnections());
		
		mAllTiles.addAll();
		mAllTiles.remove(0);
		
		{
			int current = 0;
			while (mAllTiles.size() > 0)
			{
				connectFirst(current, (current = randomOf(mAllTiles)));
				mAllTiles.remove(current);
			}
			connectFirst(current, 0);
		}
		
		mAllTiles.addAll();
		TileSet withoutTile = new TileSet(this);
		while (mAllTiles.size() > 1)
		{
			int first;
			boolean empty;
			do
			{
				empty = false;
				withoutTile.clear();
				withoutTile.addAll(mAllTiles);
				first = randomOf(mAllTiles);
				withoutTile.remove(first);
				for (int connected : mBorders.get(first))
					withoutTile.remove(connected);
				if (withoutTile.size() == 0)
				{
					empty = true;
					mAllTiles.remove(first);
				}
			}
			while (empty && mAllTiles.size() > 1);
			if (mAllTiles.size() <= 1) break;
			int second = randomOf(withoutTile);
			connect(first, second);
		}
	}