Added null check for id and added external id into the traits properly