// =====================================================
        // Things needed by the task itself...

        private void Main(ICmObject target)
        {
            var f = new RestructureDialectsDialog();

            f.ShowDialog();
            if (f.DialogResult == DialogResult.Cancel)
            {
                return;
            }

            var esb = new StringBuilder();

            esb.AppendLine("Original pairs prior to swapping: ");

            //var sda = target.Cache.DomainDataByFlid;

            //TODO: figure out how to not need target

            ILexEntryRepository repo = target.Cache.ServiceLocator.GetInstance <ILexEntryRepository>();
            var wsRepo = target.Cache.ServiceLocator.GetInstance <IWritingSystemContainer>();

            _vern = wsRepo.DefaultVernacularWritingSystem.Handle;
            _ana  = wsRepo.DefaultAnalysisWritingSystem.Handle;

            int i   = 0;
            int max = f.GetMaxToProcess();

            foreach (ILexEntry entry in repo.AllInstances())
            {
                if (i >= max)
                {
                    break;
                }

                ILexEntry vWinner = GetWinningVariant(entry, f.GetPeckingOrder());

                if (vWinner != null)
                {
                    // There is a dialectal variant we need to swap with
                    string s = Swap(entry, vWinner);
                    i++;
                    if (i < 15)
                    {
                        esb.AppendLine(s);
                    }
                    else if (i == 15)
                    {
                        esb.AppendLine("...");
                    }
                }
            }

            MessageBox.Show(esb.ToString(), f.GetPeckingOrder() + ": Made " + i + " swaps. Done restructuring.");
        }
        // =====================================================
        // Things needed by the task itself...

        private void Main(ICmObject target)
        {
            var f = new RestructureDialectsDialog();
            f.ShowDialog();
            if (f.DialogResult == DialogResult.Cancel) return;

            var esb = new StringBuilder();
            esb.AppendLine("Original pairs prior to swapping: ");

            //var sda = target.Cache.DomainDataByFlid;

            //TODO: figure out how to not need target

            ILexEntryRepository repo = target.Cache.ServiceLocator.GetInstance<ILexEntryRepository>();
            var wsRepo = target.Cache.ServiceLocator.GetInstance<IWritingSystemContainer>();
            _vern = wsRepo.DefaultVernacularWritingSystem.Handle;
            _ana = wsRepo.DefaultAnalysisWritingSystem.Handle;

            int i = 0;
            int max = f.GetMaxToProcess();
            foreach (ILexEntry entry in repo.AllInstances())
            {
                if (i >= max) break;

                ILexEntry vWinner = GetWinningVariant(entry, f.GetPeckingOrder());

                if (vWinner != null)
                {
                    // There is a dialectal variant we need to swap with
                    string s = Swap(entry, vWinner);
                    i++;
                    if (i<15)
                    {
                        esb.AppendLine(s);
                    }
                    else if(i == 15)
                    {
                        esb.AppendLine("...");
                    }
                }
            }

            MessageBox.Show(esb.ToString(), f.GetPeckingOrder() + ": Made " + i + " swaps. Done restructuring.");

        }