Fix bug with cid and removing from index
Fix incremental index remove
Use previous id for removal
Some refactoring and cleaning