Additional cleanup in id_loop()