Fixed possible cases on infinite loop on addItem and removeItem