Some corrections to id handling