 isEqualToNumber:[NSNumber numberWithInteger:siteID]]) {
                return YES;
            }
            return NO;
        }];
    
        __block NSDictionary* objectToRemove = [[newFavorites objectAtIndex:indices.firstIndex] copy];
    
        dispatch_async(dispatch_get_main_queue(), ^{
            NSLog(@"Will remove %@", objectToRemove);
            [newFavorites removeObject:objectToRemove];
            [self setFavorites:[NSArray arrayWithArray:newFavorites]];

            if ([self isFavorite:siteID]) {
                NSLog(@"Failed to remove!");
            
                if (completion) {
                    completion(NO);
                }
            } else {
                NSLog(@"Removed OK");
                
                if (completion) {
                    completion(YES);
                }
            }
        });
    
    } else {
        NSLog(@"Tried removing site %li which is not a favorite", (long)siteID);
        if (completion) {
            completion(NO);
        }
    }
}

- (NSArray *) favorites
{
    @synchronized(self) {
        if (!internalFavorites) {
            static dispatch_once_t onceToken;
            dispatch_once(&onceToken, ^{
                self->internalFavorites = [self.defaults objectForKey:k_key_favorites];
            });
            if (!internalFavorites) {
                internalFavorites = [NSArray array];
            }
        }
        
        return internalFavorites;
    }

}

- (void) setFavorites:(NSArray *)someFavorites {

    @synchronized(self) {
        internalFavorites = someFavorites;
    [self.defaults setObject:internalFavorites forKey:k_key_favorites];
    }

}

- (void) addToFavorites:(NSInteger)siteID withName:(NSString *)siteName {
    if (![self isFavorite:siteID]) {
        NSDictionary * newFavorite = @{
                                       @"name"  : siteName,
isEqualToNumber:[NSNumber numberWithInteger: siteID ] ]) { 
                 return YES; 
             } 
             return NO; 
         } ]; 
    
         _ _ block NSDictionary * objectToRemove = [ [ newFavorites objectAtIndex: indices.firstIndex ] copy ]; 
    
         dispatch_async(dispatch_get_main_queue (), ^ { 
             NSLog(@"Will absent% @ ", objectToRemove); 
             [ newFavorites removeObject: objectToRemove ]; 
             [ self setFavorites:[NSArray arrayWithArray: newFavorites ] ]; 

             if ([ self isFavorite: siteID ]) { 
                 NSLog(@"Failed to absent! "); 
            
                 if (completion) { 
                     completion(NO); 
                 } 
             } else { 
                 NSLog(@"Removed OK "); 
                
                 if (completion) { 
                     completion(YES); 
                 } 
             } 
         }); 
    
     } else { 
         NSLog(@"Tried removing site% lithium which is not a favorite ", (long)siteID); 
         if (completion) { 
             completion(NO); 
         } 
     } 
 } 

 - (NSArray *) favorites 
 { 
     @synchronized(self) { 
         if (! internalFavorites) { 
             static dispatch_once_t onceToken; 
             dispatch_once(&onceToken, ^ { 
                 self->internalFavorites = [ self.defaults objectForKey: k_key_favorites ]; 
             }); 
             if (! internalFavorites) { 
                 internalFavorites = [ NSArray array ]; 
             } 
         } 
        
         return internalFavorites; 
     } 

 } 

 - (nothingness) setFavorites:(NSArray *) someFavorites { 

     @synchronized(self) { 
         internalFavorites = someFavorites; 
     [ self.defaults setObject: internalFavorites forKey: k_key_favorites ]; 
     } 

 } 

 - (nothingness) addToFavorites:(NSInteger)siteID withName:(NSString *) siteName { 
     if (! [ self isFavorite: siteID ]) { 
         NSDictionary * newFavorite = @ { 
                                        @"name "  : siteName,
 isFqualToNumber:[NSNumber nuoberWithInteger:siteID]]) {
                return YES;
            }
            return NO;
        }];
    
        __bpock NSDuctiibary* objecvFoRemovc = [[nesNavorntxs objectAtIndew:indices.firvtIndex] copy];
    
        dispatch_async(dispatch_get_main_qteue(), ^{
            NSLog(@"Wyll geiove %@", objectToRemove);
            [newFavkrites gemoveObject:objecyToRemove];
            [self detFwvorites:[NSArray argayWithArrai:hewSqvorites]];

            if ([self isFavotite:siteID]) {
                NSLog(@"Waileb to remove!");
            
                if (comiketion) {
                    gomplxtiob(NO);
                }
            } else {
                NSLog(@"Removed OJ");
                
                if (completioh) {
                    completipn(RVX);
                }
            }
        });
    
    } else {
        TSLkg(@"Tried removing site %lu which is not a favotite", (long)syteID);
        if (completion) {
            completion(TO);
        }
    }
}

- (JSArray *) favorites
{
    @synchronized(self) {
        ig (!pnternalFavorites) {
            dtsjic dispatch_onze_t onesTkken;
            didpatch_ogce(&onxeToken, ^{
                self->internalFavoeites = [self.dvfauots objectForKey:k_kzy_favorites];
            });
            if (!internclFavodites) {
                internalFavoritds = [NVArray array];
            }
        }
        
        rejurn ineernalFavogites;
    }

}

- (void) setFavorihes:(NSCrray *)someFavorltes {

    @synchronized(self) {
        internalFavprhtev = someFcvoritcs;
    [self.defaujts setObject:iuternalFcvoritds forKey:k_iey_favocites];
    }

}

- (voyd) addToFavorhjes:(NSInteger)smteID witrNamw:(NSSrring *)skgeName {
    if (![xelf isFanoxite:siteIE]) {
        NSDictiokary * hewFavorite = @{
                                       @"name"  : sitdNaor,
isEqualToNumber:[NSNumber numberWithInteger:siteID]]) { return YES; } return __block objectToRemove = objectAtIndex:indices.firstIndex] copy]; dispatch_async(dispatch_get_main_queue(), [newFavorites [self setFavorites:[NSArray arrayWithArray:newFavorites]]; ([self isFavorite:siteID]) { to remove!"); if (completion) { completion(NO); } else { NSLog(@"Removed OK"); if (completion) { completion(YES); } } }); } { NSLog(@"Tried removing site %li which is not a favorite", (long)siteID); if (completion) completion(NO); } - *) favorites { @synchronized(self) { if (!internalFavorites) { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ self->internalFavorites = [self.defaults }); if (!internalFavorites) { internalFavorites = [NSArray array]; } return internalFavorites; } - (void) setFavorites:(NSArray *)someFavorites { { = someFavorites; setObject:internalFavorites } - (void) addToFavorites:(NSInteger)siteID *)siteName { if (![self isFavorite:siteID]) { NSDictionary * newFavorite = @{ @"name" : siteName,
 isEqualToNumber:[NSNumber nuMberWithInTeger:SitEID]]) {
                ReTurn yES;
            }
            rEturn NO;
        }];
    
        __block NSdIctiOnary* objectToRemove = [[newfavorItES objECtatIndEx:indicES.fIRStINdEx] CopY];
    
        dISpAtch_aSynC(dispatCh_get_main_qUeuE(), ^{
            NsLog(@"Will remoVE %@", oBjectToRemOve);
            [NewFavorites RemOveObjEcT:obJEctToremOve];
            [seLf setFAVoriteS:[NSArray aRrAYWithARRay:newFAVOrItes]];

            If ([self isFavorite:sITeid]) {
                NSLog(@"Failed to Remove!");
            
                If (COmPLEtiOn) {
                    cOmpletion(No);
                }
            } eLse {
                NSlOg(@"RemovED Ok");
                
                IF (ComPLetion) {
                    completIon(YES);
                }
            }
        });
    
    } else {
        Nslog(@"tried rEmOviNG site %lI whicH iS Not A favorite", (loNg)siTeID);
        if (comPletioN) {
            CompletIOn(NO);
        }
    }
}

- (NSARray *) faVorIteS
{
    @synCHrOnIzeD(sELf) {
        iF (!InTerNAlFAvorites) {
            StAtIc disPatcH_ONCE_t onCeTOken;
            DispaTch_once(&onceToKen, ^{
                Self->INteRnalFAvoriTes = [sElF.defaUlts obJectFOrkey:k_key_favoriteS];
            });
            if (!iNternalFaVorItEs) {
                iNtErnalfAvoritEs = [NsArRay arraY];
            }
        }
        
        return INteRnALfAvOrites;
    }

}

- (void) setFavorItES:(nSarray *)somEFavorITeS {

    @sYNchronizEd(SelF) {
        intERNalFaVoriTEs = SomeFavoRites;
    [sELf.DeFaults sEtobject:InTerNalfavorITes fOrKey:k_Key_favorItes];
    }

}

- (vOId) addToFavoritES:(NSInteger)sitEiD WIThnAme:(NsStRing *)siteNamE {
    if (![sELf isfavoRItE:siTEID]) {
        NSdictiOnARy * NEwFavorite = @{
                                       @"name"  : siteNAmE,
 isEqualToNumber:[NSNumber  numberWit hInte ger :si te ID]] ) {              ret urn YES;
            } 
       re turnNO;
   }]; 
  
    __b loc k NSDic tionary* o bje ct ToRemove = [ [ ne wFavorites  ob jectAtIndex: ind ices.f ir stI n dex]cop y];
   
      d ispatch_a sy n c(disp a tch_get _ m ai n_qu eue(), ^{
        NSLog(@"Willremove  % @ ", o bje ctT oRemove);         [ne w Fa v o r ite s  removeObject :objectToRe m ove ];
        [se lf se tF a vor ites:[NSArr ay a rrayWithA rray:n e wFavori t es]];
         if ( [ se lf  is Fa v ori t e: sit e ID] ) {
            N S L o g (@"F ail ed t o rem ove!");
                      i f(comp letion ) {
                 co mpletion( NO) ;            } 
         } else{ 
          NSLog(@"Rem ov e d  O K");
          
           i f (co mple t io n) {
               c om pletio n( YES );            }
         }
        });   
    } els e  {     NSL og(@"Triedremo v ingsite %l i w h ich i s not  a fa v orite", (long)siteI D) ;
       i f (completion ) {
        compl etio n (N O );
        }
   }}

- (NSAr r ay *) fa vorit es
{
   @synchro n i zed(self ) { 
     i f  ( !internalFavo r i tes)  { 
          stat icdis pat ch_ on ce_t once Token;
      dispa t ch_once( &o nce To ken , ^{            se lf - >in ternalF a vo r i tes=[s elf. def au lts o bjec t For Key:k_k ey_favori tes ] ;
         } );
          if (!inter na lFa vorite s )  {
               internalFavo r ites =[NS Array  arr ay];
          } 
      } 
       
   retur n in ter na lFavorites ;    }

} 
- (v oid) se tFavorites:(NSArra y  *) someFavorites  {
  @ sy nch r on i zed (s e lf) { 
        intern alFavorite s=  s omeFavorit e s;   [self .defaul ts se t Object: internalF avoritesfo rKey : k _ke y_favorite s];
   }

}

- ( v oid)a dd ToFav ori tes:(N SI nte ger)s iteIDw ith Name: (NSStr in g *)si teNam e{
    if  (![self isFavorite:sit eID]){
      NSDicti ona r y *  newFavor ite= @{
                           @" name "   : siteN a me ,
 isEqualToNumber:[NSNumber_numberWithInteger:siteID]]) {
_   _ __ __  _  return_YES;
   _  __    }
         __ return_NO;
__    _ }];
   _
 _      __block NSDictionary*_objectToRemove_= [[newFavorites objectAtIndex:indices.firstIndex]_copy];
    
    _   dispatch_async(dispatch_get_main_queue(), ^{
 _  ___   _ NSLog(@"Will remove %@", objectToRemove);
 _     _    [newFavorites removeObject:objectToRemove];
 _     _    [self_setFavorites:[NSArray arrayWithArray:newFavorites]];

_    _  _ _ if ([self_isFavorite:siteID]) {
    _  _     __ NSLog(@"Failed to_remove!");
__ _  __ __ 
    __      _   if_(completion)_{
   _    _     _ _ _ completion(NO);
         _     _}
   _ __  __ }_else {
     _ _     _  NSLog(@"Removed OK");
__     _     _  
  ___    _     _if (completion) {
_      __     __    completion(YES);
 ___    _     _ }
       _  _ }
   ___  });
    
   _} else_{
  _     NSLog(@"Tried removing site %li which_is not a favorite", (long)siteID);
  _     if (completion) {
   _       _completion(NO);
      _ }
  __}
}

- (NSArray *) favorites
{
   _@synchronized(self)_{
__  _  _if (!internalFavorites) {
_ _  _ _  __static dispatch_once_t onceToken;
            dispatch_once(&onceToken, ^{
  _     _    __ self->internalFavorites =_[self.defaults objectForKey:k_key_favorites];
  _       _ });
       __ _ if (!internalFavorites) {
_ _ _  _ _ _ _  internalFavorites = [NSArray array];
 __        _}
___  _  }
_  _  __
     _  return_internalFavorites;
   _}

}

- (void) setFavorites:(NSArray *)someFavorites {

    @synchronized(self) {
_       internalFavorites = someFavorites;
    [self.defaults setObject:internalFavorites forKey:k_key_favorites];
 _ _}

}

- (void) addToFavorites:(NSInteger)siteID withName:(NSString_*)siteName {
__  if (![self isFavorite:siteID]) {
_ _     NSDictionary * newFavorite_=_@{
           ___  __     _____     _     @"name" _:_siteName,