Fixed array handling in copyCollectionOrArray utility method