Proper Device ID?

I am trying to develop a web application that analyzes heart_rate and wattage data from Garmin devices. I currently use a Fenix5, but would like to extend the application to any Garmin device that supports the HR and wattage data. I use the fitdecode python toolkit, which I believe is based on the Garmin Fit SDK. They have a routine that outputs a json file from the .fit file that I use for debugging. My issue is finding the correct device identifier information. 
The device I use is a Garmin Fenix5, with serial number 3950279784. I see the word Garmin appear many times in the json. The first time, it is in "frame_type": "data_message","name": "file_id", where the 'device_id' is correct. For the next 6 records with 'Garmin', "frame_type" = "data_message", "name" = "device_info", but sometimes the 'serial_number' = null, but other times it is correct, but still others it is wrong. 'Garmin' appears 7 times for rows < 2000 in the test file, the first being the "frame_type": "data_message","name": "file_id" and the next 6 have "frame_type": "data_message", "name": "device_info". Then there is a huge gap to rows > 755,000 where 'Garmin' appears again for 6 records "frame_type": "data_message", "name": "device_info", that appear similar to the first set of six. But, same issue, sometimes serial_number is null, sometimes OK, sometimes wrong.
My questions are: 1) is there a simple way to get the device serial number correctly? 2) why are there so many records with serial number, some null, some correct and some not correct? Is it related to laps or the possibility of chained files (the file I am working on came from one device, for a 40+ minute bike ride).
Appreciate your help.
 I can send the .fit file or json (which is huge) if it would help.