Added _updateItemCount function and fixed a bug where `remove` didn't update the item count.