Fix problem with reusing IDs