Improve comments and naming regarding array flattening function