fix the errors in the google earth engine script:

Area Vereda Ratio: Tile error: Too many concurrent aggregations
Area Vereda Ratio: Tile error: Expected a homogeneous image collection, but an image with an incompatible band was encountered. Mismatched type for band 'ratio1':
Expected type: Float<34.42520312730182, 34.42520312730182>.
 Actual type: Float<37.30350188183043, 37.30350188183043>.
 Image ID: null
This band might require an explicit cast.

Area Vereda Ratio: Tile error: Expected a homogeneous image collection, but an image with an incompatible band was encountered. Mismatched type for band 'ratio1':
Expected type: Float<34.42520312730182, 34.42520312730182>.
 Actual type: Float<66.68419372792196, 66.68419372792196>.
 Image ID: null
This band might require an explicit cast.
Area Vereda Ratio: Tile error: Expected a homogeneous image collection, but an image with an incompatible band was encountered. Mismatched type for band 'ratio1':
Expected type: Float<34.42520312730182, 34.42520312730182>.
 Actual type: Float<37.30350188183043, 37.30350188183043>.
 Image ID: null
This band might require an explicit cast.]

Print the correction. The script: Map.setOptions("SATELLITE"); // "ROADMAP", "SATELLITE", "HYBRID" or "TERRAIN"

var geometry = 
    ee.Geometry.Polygon(
        [[[-48.90990751290743, -8.920219511710798],
          [-48.90990751290743, -16.649225798686256],
          [-42.66967313790743, -16.649225798686256],
          [-42.66967313790743, -8.920219511710798]]], null, false);

var table4 = ee.FeatureCollection("projects/ee-maximoicmbio/assets/ottobacias_n5_urucuia_veredas_doc");

Map.addLayer(table4, {}, 'teste')

var veredasmapbiomasfreq = ee.FeatureCollection("users/maximomenezesgee/Otto_4_Urucuia_mapbiomas_veredas_Union2");
var arenizacao = ee.FeatureCollection("users/maximomenezesgee/Otto_4_Urucuia_Landsat_Union_arenizacao3");

var mascara1 = ee.Image(100).toInt().clip(veredasmapbiomasfreq);
var mascara2 = ee.Image(200).toInt().clip(arenizacao);

var mascara3 = ee.Image([mascara2, mascara1])
  .reduce(ee.Reducer.firstNonNull());

var verd_areniz1 = ee.Image("users/maximomenezesgee/campo_arenizacao_landsat_doutorado_raster")
  .select('arenizacao_count')
  .updateMask(mascara3);

var verd_areniz = ee.Image(300).toInt().updateMask(verd_areniz1);

var imagebands1 = ee.Image([
  mascara3.updateMask(mascara3.eq(100)),
  mascara3.updateMask(mascara3.eq(200))
]).rename('vereda', 'arenizacao');

var mascara4 = ee.Image([verd_areniz, mascara1])
  .reduce(ee.Reducer.firstNonNull());

var imagebands2 = ee.Image([
  mascara4.updateMask(mascara4.eq(100)),
  mascara4.updateMask(mascara4.eq(300))
]).rename('vereda','freq_arenizacao');
print(imagebands2)

Map.addLayer(imagebands1.select('vereda'), {
  min: 1,
  max: 200,
  palette: ['#9400D3', '#4B0082', '#0000FF', '#00FF00', '#FFFF00', '#FF7F00', '#FF0000']
}, 'Arenizacao_freq');

Map.addLayer(imagebands1.select('arenizacao'), {
  min: 1,
  max: 200,
  palette: ['#9400D3', '#4B0082', '#0000FF', '#00FF00', '#FFFF00', '#FF7F00', '#FF0000']
}, 'Arenizacao', null, 0.4);

// Função para calcular a área em hectares
var calculateArea = function(image) {
  var areaImage = image.multiply(ee.Image.pixelArea()).divide(10000); // Convert to hectares
  var totalArea = areaImage.reduceRegion({
    reducer: ee.Reducer.sum(),
    geometry: geometry,
    scale: 30,
    maxPixels: 1e13,
    bestEffort: true
  });
  
  return ee.Number(totalArea.get(image.bandNames().get(0))); // Retorna um ee.Number
};

// Calcula a área para cada classe na imagem
var areaVereda = calculateArea(imagebands1.select('vereda'));
var areaArenizacao = calculateArea(imagebands1.select('arenizacao'));

// Total da área
var totalArea = areaVereda.add(areaArenizacao);

//print(areaVereda, 'areaVereda')
//print(areaArenizacao, 'areaArenizacao')
//print(totalArea, 'totalArea')

// Calcula a porcentagem
var percentageVereda = areaVereda.divide(totalArea).multiply(100);
var percentageArenizacao = areaArenizacao.divide(totalArea).multiply(100);

// Prepara os dados para o gráfico de pizza
var pieChartData = ee.FeatureCollection([
  ee.Feature(null, {label: 'Vereda', area: percentageVereda}),
  ee.Feature(null, {label: 'Arenização', area: percentageArenizacao})
]);

var chart1 = ui.Chart.feature.byFeature(pieChartData, 'label', 'area')
  .setChartType('PieChart')//'ScatterChart', 'LineChart', 'ColumnChart', PieChart
  .setOptions({
    title: 'Porcentagem arenização',
    colors: ['#FF0000', '#00FF00'],
  });
print(chart1);

// Calcula a área para a frequência
var areaFreqVereda = calculateArea(imagebands2.select('vereda'));
var areaFreqArenizacao = calculateArea(imagebands2.select('freq_arenizacao'));

// Total da área de frequência
var totalFreqArea = areaFreqVereda.add(areaFreqArenizacao);

// Calcula a porcentagem de frequência
var percentageFreqVereda = areaFreqVereda.divide(totalFreqArea).multiply(100);
var percentageFreqArenizacao = areaFreqArenizacao.divide(totalFreqArea).multiply(100);

// Prepara os dados para o gráfico de pizza de frequência
var pieChartFreqData = ee.FeatureCollection([
  ee.Feature(null, {label: 'Vereda', area: percentageFreqVereda}),
  ee.Feature(null, {label: 'Frequência Arenização', area: percentageFreqArenizacao})
]);

var chart2 = ui.Chart.feature.byFeature(pieChartFreqData, 'label', 'area')
  .setChartType('PieChart')//'ScatterChart', 'LineChart', 'ColumnChart', 'PieChart'
  .setOptions({
    title: 'Porcentagem arenização (frequência)',
    colors: ['#FF0000', '#00FF00'],
  });
print(chart2);

//_____________________________________________
// 1. Function to Calculate Area and Percentage for each feature
var calculateAreaAndPercentage = function(feature) {
  var geometry = feature.geometry();

  // Calculate areas in hectares for the first image
  var areaVereda1 = calculateArea(imagebands1.select('vereda').clip(geometry));
  var areaArenizacao1 = calculateArea(imagebands1.select('arenizacao').clip(geometry));
  var totalArea1 = areaVereda1.add(areaArenizacao1);
  
  var percentageVereda1 = areaVereda1.divide(totalArea1).multiply(100);
  var percentageArenizacao1 = areaArenizacao1.divide(totalArea1).multiply(100);
  
  // Calculate areas for the second image
  var areaVereda2 = calculateArea(imagebands2.select('vereda').clip(geometry));
  var areaFreqArenizacao2 = calculateArea(imagebands2.select('freq_arenizacao').clip(geometry));
  var totalArea2 = areaVereda2.add(areaFreqArenizacao2);
  
  var percentageVereda2 = areaVereda2.divide(totalArea2).multiply(100);
  var percentageFreqArenizacao2 = areaFreqArenizacao2.divide(totalArea2).multiply(100);
  
  // Update properties of the feature
  return feature.set({
    'area_vereda_1': areaVereda1,
    'area_arenizacao_1': areaArenizacao1,
    'percentage_vereda_1': percentageVereda1,
    'percentage_arenizacao_1': percentageArenizacao1,
    'area_vereda_2': areaVereda2,
    'area_freq_arenizacao_2': areaFreqArenizacao2,
    'percentage_vereda_2': percentageVereda2,
    'percentage_freq_arenizacao_2': percentageFreqArenizacao2
  });
};

// Map the area calculation function over the FeatureCollection and store the updated features
var updatedTable4 = table4.map(calculateAreaAndPercentage);

// 2. Generate Images for Visualization
var generateAreaImage = function(feature) {
  var areaVereda1 = feature.getNumber('area_vereda_1');
  var areaArenizacao1 = feature.getNumber('area_arenizacao_1');
  var ratio1 = ee.Algorithms.If(areaVereda1.add(areaArenizacao1).gt(0), 
                                areaVereda1.divide(areaVereda1.add(areaArenizacao1)).multiply(100), 
                                0); // Handle cases where total area is zero

  var areaVereda2 = feature.getNumber('area_vereda_2');
  var areaFreqArenizacao2 = feature.getNumber('area_freq_arenizacao_2');
  var ratio2 = ee.Algorithms.If(areaVereda2.add(areaFreqArenizacao2).gt(0), 
                                areaVereda2.divide(areaVereda2.add(areaFreqArenizacao2)).multiply(100), 
                                0); // Handle cases where total area is zero

  // Create images for each ratio
  var image1 = ee.Image.constant(ratio1).rename('ratio1').clip(feature.geometry());
  var image2 = ee.Image.constant(ratio2).rename('ratio2').clip(feature.geometry());

  return image1.addBands(image2);
};

// Generate images for each feature and convert to an ImageCollection
var areaImages = updatedTable4.map(generateAreaImage)
                              .map(function(feature) { return ee.Image(feature); }); // Convert features to images

var areaImageCollection = ee.ImageCollection(areaImages); // Create ImageCollection from the images

// Create a mosaic from the ImageCollection
var finalImage = areaImageCollection.mosaic();

// Visualize the final image
Map.centerObject(table4, 8); // Center Map
Map.addLayer(finalImage.select('ratio1'), {min: 0, max: 100, palette: ['blue', 'green', 'red']}, 'Area Vereda Ratio');
Map.addLayer(finalImage.select('ratio2'), {min: 0, max: 100, palette: ['blue', 'green', 'yellow']}, 'Area Frequency Arenizacao Ratio');