Fix the internal type of array_agg and add a generic TArray type