(maint) Untangle fetching of serial numbers
The previous code contained a large number of assignments in passing
inside the conditional expressions. This caused it to need to use the
"and" operator, which should be reserved for control flow, to be used as
a boolean expression in order to avoid having the list of serial numbers
be a boolean as a result of precedence. This also resulted in the name
"serial" being used, when in fact it is now a collection of 0 or more
serial numbers. It also had the structure where the final array could
have been an array of arrays and so flatten needed to be used.
This straightens all of that out by ensuring that serials is always an
array and performing common error checking and handling of that.