Fix invalid id's generation.