Extensive rework of concat hook function to support merged array return values