for ($innerCounter = $i + 1; $innerCounter <= count($oldestToNewestDS) - 1; $innerCounter++) {
         $innerDSChecksum = $oldestToNewestDS[$innerCounter]['dsChecksum'];
         $nextInnerDSChecksum = $oldestToNewestDS[$innerCounter + 1]['dsChecksum'];
         // drush_print(' INNER: Comparing checksum of ' . $oldestToNewestDS[$innerCounter]['dsVersionID'] . ' to checksum of ' . $oldestToNewestDS[$innerCounter + 1]['dsVersionID']);
         if ($innerDSChecksum === $nextInnerDSChecksum) {
             $toBeRemoved[] = $oldestToNewestDS[$innerCounter + 1];
             continue;
         } else {
             $totalDSSize = 0;
             foreach ($toBeRemoved as $ds) {
                 $totalDSSize += $ds['dsSize'];
             }
             // remove from $currentDS to $oldestToNewestDS[$innerCounter]
             // drush_print(' INNER: Checksums are different, removing from ' . $currentDS['dsVersionID'] . ' to ' . $oldestToNewestDS[$innerCounter]['dsVersionID']);
             try {
                 $api_m->purgeDatastream($objectPID, $datastream->label, array('startDT' => createMicrosecondDT($currentDS, "+1"), 'endDT' => createMicrosecondDT($oldestToNewestDS[$innerCounter]), 'logMessage' => ''));
                 $spaceFreed += $totalDSSize;
                 $mainCounter = count($api_m->getDatastreamHistory($objectPID, $datastream->label));
                 $oldestToNewestDS = array_reverse($api_m->getDatastreamHistory($objectPID, $datastream->label));
                 // print_r($oldestToNewestDS);
                 break;
             } catch (Exception $e) {
                 drush_print("***ERROR: skipping deletion of " . $datastream->label . " datastream for {$objectPID}***");
                 $objectsWithProblems[] = $objectPID;
                 break;
             }
         }
     }
 } else {
     // drush_print('OUTER: value of checksums for ' . $currentDS['dsVersionID'] . ' and ' . $nextDS['dsVersionID'] . ' are different, going to next DS');
     continue;
 // NB: ds's are returned in order from most to least recent
 $currentDS = $dshistory[0];
 $previousDS = $dshistory[1];
 //    $oldestToNewestDS = array_reverse($dshistory);
 //    $startingDSNumber += count($oldestToNewestDS);
 //    drush_print("Most recent datastream version:");
 print_r($currentDS);
 //    drush_print("Previous datastream version:");
 //    print_r($previousDS);
 //	print_r(createMicrosecondDT($currentDS, "-1") . "\n");
 //	print_r(createMicrosecondDT($currentDS, "+1") . "\n");
 drush_print("************************************************");
 //    $oldestDS = $oldestToNewestDS[0];
 //    $mainCounter = count($oldestToNewestDS) - 1;
 try {
     $api_m->purgeDatastream($objectPID, $dslabel, array('startDT' => createMicrosecondDT($currentDS, "-1"), 'endDT' => createMicrosecondDT($currentDS, "+1"), 'logMessage' => ''));
     //        $spaceFreed += $totalDSSize;
     //        $mainCounter = count($api_m->getDatastreamHistory($objectPID, $dslabel));
     //        $oldestToNewestDS = array_reverse($api_m->getDatastreamHistory($objectPID, $dslabel));
     // print_r($oldestToNewestDS);
     //        break;
 } catch (Exception $e) {
     drush_print("***ERROR: skipping deletion of most recent datastream version***");
     $objectsWithProblems[] = $objectPID;
     //        break;
 }
 /*
     for ($i = 0; $i <= $mainCounter; $i ++) {
         // drush_print("OUTER: value of i is $i");
         $currentDS = $oldestToNewestDS[$i];
         $nextDS = $oldestToNewestDS[$i + 1];