Fixes to ID setting code