Fixing some bugs from the last bit of changes
assign the Id as well