The comment here says "make sure all cid values are consecutive." What does this new code do?