diff --git a/src/cluster/cluster.cpp b/src/cluster/cluster.cpp
index 999a6835c731b679c526f0bbf40ac72ca90e96f4..a04f151e7c356142a41d5a4d09ba37cdfc53e2c6 100644
--- a/src/cluster/cluster.cpp
+++ b/src/cluster/cluster.cpp
@@ -348,7 +348,7 @@ void cluster(string config_file, string data_file, string output_path) {
       int ompnumthreads = 1;
 #pragma omp parallel
       {
-	// To test parallelism, I will now start feeding this function with "clean" copies of the parameters, so that they will not be changed by previous iterations, and each one will behave as the first one
+        // To test parallelism, I will now start feeding this function with "clean" copies of the parameters, so that they will not be changed by previous iterations, and each one will behave as the first one
 	ScattererConfiguration *sconf_2 = new ScattererConfiguration(*sconf);
 	GeometryConfiguration *gconf_2 = new GeometryConfiguration(*gconf);
 	C1 *c1_2 = new C1(*c1);
@@ -531,7 +531,7 @@ void cluster(string config_file, string data_file, string output_path) {
 
 #pragma omp for
 	for (jxi488 = 2; jxi488 <= nxi; jxi488++) {
-	jer = cluster_jxi488_cycle(jxi488, sconf_2, gconf_2, c1_2, c1ao_2, c2_2, c3_2, c4_2, c6_2, c9_2, output_2, output_path, gaps_2, tqse_2, tqspe_2, tqss_2, tqsps_2, zpv_2, gapm_2, gappm_2, nth_2, nths_2, nph_2, nphs_2, nk_2, nks_2, nkks_2, argi_2, args_2, gap_2, gapp_2, tqce_2, tqcpe_2, tqcs_2, tqcps_2, duk_2, tppoan_2, cextlr_2, cext_2, cmullr_2, cmul_2, gapv_2, tqev_2, tqsv_2, nxi_2, nsph_2, mxndm_2, inpol_2, iavm_2, npnt_2, npntts_2, isam_2, lm_2, th_2, thstp_2, thlst_2, ths_2, thsstp_2, thslst_2, ph_2, phstp_2, phlst_2, phs_2, phsstp_2, phslst_2, th1_2, ph1_2, ths1_2, phs1_2, thsca_2, u_2, us_2, un_2, uns_2, up_2, ups_2, unmp_2, unsmp_2, upmp_2, upsmp_2, scan_2, cfmp_2, sfmp_2, cfsp_2, sfsp_2, sqsfi_2, exri_2, lcalc_2, arg_2, wn_2, vk_2, ndit_2, am_2, isq_2, ibf_2);
+	  jer = cluster_jxi488_cycle(jxi488, sconf_2, gconf_2, c1_2, c1ao_2, c2_2, c3_2, c4_2, c6_2, c9_2, output_2, output_path, gaps_2, tqse_2, tqspe_2, tqss_2, tqsps_2, zpv_2, gapm_2, gappm_2, nth_2, nths_2, nph_2, nphs_2, nk_2, nks_2, nkks_2, argi_2, args_2, gap_2, gapp_2, tqce_2, tqcpe_2, tqcs_2, tqcps_2, duk_2, tppoan_2, cextlr_2, cext_2, cmullr_2, cmul_2, gapv_2, tqev_2, tqsv_2, nxi_2, nsph_2, mxndm_2, inpol_2, iavm_2, npnt_2, npntts_2, isam_2, lm_2, th_2, thstp_2, thlst_2, ths_2, thsstp_2, thslst_2, ph_2, phstp_2, phlst_2, phs_2, phsstp_2, phslst_2, th1_2, ph1_2, ths1_2, phs1_2, thsca_2, u_2, us_2, un_2, uns_2, up_2, ups_2, unmp_2, unsmp_2, upmp_2, upsmp_2, scan_2, cfmp_2, sfmp_2, cfsp_2, sfsp_2, sqsfi_2, exri_2, lcalc_2, arg_2, wn_2, vk_2, ndit_2, am_2, isq_2, ibf_2);
 	}
 	
 	delete sconf_2;
@@ -615,12 +615,12 @@ void cluster(string config_file, string data_file, string output_path) {
 	delete[] am_vector_2;
 	delete[] am_2;
 	
-      } // jxi488 loop
+      } // jxi488 loop and omp parallel
 #ifdef _OPENMP
       for (int ri = 0; ri < ompnumthreads; ri++) {
       // Giovanni, please add here in this loop code to reopen the temporary files, reread them and append them respectively to the global output and tppoan, before closing them
 	string partial_file_name = output_path + "/c_OCLU_" + to_string(ri);
-	printf("Copying ASCII output of thread %d of %d... ", ri, ompnumthreads);
+	printf("Copying ASCII output of thread %d of %d... ", ri, ompnumthreads - 1);
 	FILE *partial_output = fopen(partial_file_name.c_str(), "r");
 	char c = fgetc(partial_output);
 	while (c != EOF) {
@@ -630,16 +630,20 @@ void cluster(string config_file, string data_file, string output_path) {
 	fclose(partial_output);
 	remove(partial_file_name.c_str());
 	printf("done.\n");
-	partial_file_name = output_path + "/c_TPPOAN_" + to_string(ri);
-	printf("Copying binary output of thread %d of %d... ", ri, ompnumthreads);
+      }
+      for (int ri = 0; ri < ompnumthreads; ri++) {
+	string partial_file_name = output_path + "/c_TPPOAN_" + to_string(ri);
+	printf("Copying binary output of thread %d of %d... ", ri, ompnumthreads - 1);
 	fstream partial_tppoan;
-	partial_tppoan.open((output_path + "/c_TPPOAN_" + to_string(ri)).c_str(), ios::in | ios::binary);
-	c = partial_tppoan.get();
-	while(!partial_tppoan.eof()) {
-	  tppoan.put(c);
-	  c = partial_tppoan.get();
-	}
+	partial_tppoan.open(partial_file_name.c_str(), ios::in | ios::binary);
+	partial_tppoan.seekg(0, ios::end);
+	long buffer_size = partial_tppoan.tellg();
+	char *binary_buffer = new char[buffer_size];
+	partial_tppoan.seekg(0, ios::beg);
+	partial_tppoan.read(binary_buffer, buffer_size);
+	tppoan.write(binary_buffer, buffer_size);
 	partial_tppoan.close();
+	delete[] binary_buffer;
 	remove(partial_file_name.c_str());
 	printf("done.\n");
       }