anchor.diff:              session.JobStartTime <- DateTime.Now
               session.ThreadCount <- req.ThreadCount
               let parallelOptions = new ParallelOptions(MaxDegreeOfParallelism = session.ThreadCount)
  -            let dateTimeField = indexWriter.GetSchemaName(session.DateTimeField)
  -            let mainQuery = 
  +            let dateTimeField = session.DateTimeField //indexWriter.GetSchemaName(session.DateTimeField)
  +            let mainQueryString = 
                   sprintf "%s > '%i' AND %s < '%i'" dateTimeField (session.RangeStartTime |> dateToFlexFormat) 
                       dateTimeField (session.RangeEndTime |> dateToFlexFormat)
  -            let mainQuery = new SearchQuery.Dto(session.IndexName, mainQuery, Count = (int32) System.Int16.MaxValue)
  +            Debug.WriteLine("Main Query:" + mainQueryString)
  +            let mainQuery = 
  +                new SearchQuery.Dto(session.IndexName, mainQueryString, Count = (int32) System.Int16.MaxValue)
               // TODO: Future optimization: bring only the required columns
  +            mainQuery.ReturnFlatResult <- true
               mainQuery.Columns <- [| "*" |]
  -            let! result = searchService.Search(mainQuery)
  -            let records = result |> toFlatResults
  -            session.RecordsReturned <- result.Meta.RecordsReturned
  -            session.RecordsAvailable <- result.Meta.TotalAvailable
  -            let session = writeSessionBeginInfo (req, session)
  -            Parallel.ForEach
  -                (records.Documents, parallelOptions, fun record -> duplicateRecordCheck (req, record, session)) 
  -            |> ignore
  -            session.JobEndTime <- DateTime.Now
  -            writeSessionEndInfo (req, session)
  -        }
  +            let resultC = searchService.Search(mainQuery)
  +            match resultC with
  +            | Choice1Of2(result) -> 
  +                Debug.WriteLine("Main Query Records Returned:" + result.Meta.RecordsReturned.ToString())
  +                let records = result |> toFlatResults
  +                session.RecordsReturned <- result.Meta.RecordsReturned
  +                session.RecordsAvailable <- result.Meta.TotalAvailable
  +                let session = writeSessionBeginInfo (req, session)
  +                try 
  +                    let _ = 
  +                        Parallel.ForEach
  +                            (records.Documents, parallelOptions, 
  +                             fun record -> duplicateRecordCheck (req, record, session))
  +                    ()
  +                with :? AggregateException as e -> Log.errorEx (e)
  +                session.JobEndTime <- DateTime.Now
  +                writeSessionEndInfo (req, session)
  +            | Choice2Of2(err) -> Log.errorMsg (err) |> ignore
  +        with e -> Log.errorEx (e)
  +        Debug.WriteLine("Dedupe Session Finished.")
       
       let requestProcessor = 
           MailboxProcessor.Start(fun inbox -> 
  
positive.code:                             (new LineItem(SecondaryRecordId = result.[Constants.IdField], 
                                            DisplayName = result.[session.DisplayFieldName], Score = score, 
                                            HeaderId = header.HeaderId)) |> ignore
                          if req.GenerateReport then fileWriter.Post(AddRecord result, req.ReportName)
                  if req.GenerateReport then fileWriter.Post(EndTable, req.ReportName)
                  context.SaveChanges() |> ignore
          | _ -> ()
      
      let performDuplicateDetection (jobId, indexWriter : IndexWriter.T, req : DuplicateDetectionRequest) = 
          maybe { 
              let session = new Session()
              session.IndexName <- req.IndexName
              session.ProfileName <- req.ProfileName
  
negative.code: open System.Collections.Generic
  open System.ComponentModel.DataAnnotations.Schema
  open System.Data.Entity
  open System.Diagnostics
  open System.IO
  open System.Text
  open System.Threading.Tasks
  