Make 'ids' synchronized as explained in #1566