diff --git a/openair1/PHY/LTE_TRANSPORT/dci.c b/openair1/PHY/LTE_TRANSPORT/dci.c
index f126d0e2eabbcf68e057396b161d68d7d0e74f7a..70761ac5aea2fd11d921dafcc27662e58e4744aa 100644
--- a/openair1/PHY/LTE_TRANSPORT/dci.c
+++ b/openair1/PHY/LTE_TRANSPORT/dci.c
@@ -2546,6 +2546,107 @@ uint16_t get_nCCE_mac(uint8_t Mod_id,uint8_t CC_id,int num_pdcch_symbols,int sub
 		  get_mi(&PHY_vars_eNB_g[Mod_id][CC_id]->lte_frame_parms,subframe))); 
 }
 
+
+int get_nCCE_offset_l1(int *CCE_table,
+		       const unsigned char L, 
+		       const int nCCE, 
+		       const int common_dci, 
+		       const unsigned short rnti, 
+		       const unsigned char subframe)
+{
+
+  int search_space_free,m,nb_candidates = 0,l,i;
+  unsigned int Yk;
+   /*
+    printf("CCE Allocation: ");
+    for (i=0;i<nCCE;i++)
+    printf("%d.",CCE_table[i]);
+    printf("\n");
+  */
+  if (common_dci == 1) {
+    // check CCE(0 ... L-1)
+    nb_candidates = (L==4) ? 4 : 2;
+    nb_candidates = min(nb_candidates,nCCE/L);
+
+    //    printf("Common DCI nb_candidates %d, L %d\n",nb_candidates,L);
+
+    for (m = nb_candidates-1 ; m >=0 ; m--) {
+
+      search_space_free = 1;
+      for (l=0; l<L; l++) {
+
+	//	printf("CCE_table[%d] %d\n",(m*L)+l,CCE_table[(m*L)+l]);
+        if (CCE_table[(m*L) + l] == 1) {
+          search_space_free = 0;
+          break;
+        }
+      }
+     
+      if (search_space_free == 1) {
+
+	//	printf("returning %d\n",m*L);
+
+        for (l=0; l<L; l++)
+          CCE_table[(m*L)+l]=1;
+        return(m*L);
+      }
+    }
+
+    return(-1);
+
+  } else { // Find first available in ue specific search space
+    // according to procedure in Section 9.1.1 of 36.213 (v. 8.6)
+    // compute Yk
+    Yk = (unsigned int)rnti;
+
+    for (i=0; i<=subframe; i++)
+      Yk = (Yk*39827)%65537;
+
+    Yk = Yk % (nCCE/L);
+
+
+    switch (L) {
+    case 1:
+    case 2:
+      nb_candidates = 6;
+      break;
+
+    case 4:
+    case 8:
+      nb_candidates = 2;
+      break;
+
+    default:
+      DevParam(L, nCCE, rnti);
+      break;
+    }
+
+
+    LOG_D(MAC,"rnti %x, Yk = %d, nCCE %d (nCCE/L %d),nb_cand %d\n",rnti,Yk,nCCE,nCCE/L,nb_candidates);
+
+    for (m = 0 ; m < nb_candidates ; m++) {
+      search_space_free = 1;
+
+      for (l=0; l<L; l++) {
+        if (CCE_table[(((Yk+m)%(nCCE/L))*L) + l] == 1) {
+          search_space_free = 0;
+          break;
+        }
+      }
+
+      if (search_space_free == 1) {
+        for (l=0; l<L; l++)
+          CCE_table[(((Yk+m)%(nCCE/L))*L)+l]=1;
+
+        return(((Yk+m)%(nCCE/L))*L);
+      }
+    }
+
+    return(-1);
+  }
+}
+
+
 void dci_decoding_procedure0(LTE_UE_PDCCH **lte_ue_pdcch_vars,
 			     int do_common,
 			     uint8_t subframe,
diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c
index 5a8dd1ab90c3b5364291313da581b9680e0080cb..b3d2272107c11b84aaf2307f134159b9da598213 100644
--- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c
+++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c
@@ -2667,7 +2667,7 @@ int generate_eNB_dlsch_params_from_dci(int frame,
     dlsch1_harq->subframe = subframe;
   }
 
-  //#ifdef DEBUG_DCI
+#ifdef DEBUG_DCI
 
   if (dlsch0) {
     printf("dlsch0 eNB: dlsch0   %p\n",dlsch0);
@@ -2683,7 +2683,7 @@ int generate_eNB_dlsch_params_from_dci(int frame,
     printf("dlsch0 eNB: mimo_mode %d\n",dlsch0_harq->mimo_mode);
   }
 
-  //#endif
+#endif
 
   // compute DL power control parameters
   computeRhoA_eNB(pdsch_config_dedicated, dlsch[0],dlsch0_harq->dl_power_off);
@@ -5534,7 +5534,7 @@ int generate_ue_dlsch_params_from_dci(int frame,
   }
 
 
-  //#ifdef DEBUG_DCI
+#ifdef DEBUG_DCI
 
   if (dlsch[0]) {
     printf("PDSCH dlsch0 UE: rnti     %x\n",dlsch[0]->rnti);
@@ -5548,7 +5548,7 @@ int generate_ue_dlsch_params_from_dci(int frame,
     printf("PDSCH dlsch0 UE: pwr_off  %d\n",dlsch0_harq->dl_power_off);
   }
 
-  //#endif
+#endif
   dlsch[0]->active=1;
 
   // compute DL power control parameters
diff --git a/openair1/PHY/LTE_TRANSPORT/proto.h b/openair1/PHY/LTE_TRANSPORT/proto.h
index 16fe3cafc78d13e10f4842a9ccea80a5be5201c2..7b1cd6ed284dc2bf5789f2ce71ee5dc8d4b34931 100644
--- a/openair1/PHY/LTE_TRANSPORT/proto.h
+++ b/openair1/PHY/LTE_TRANSPORT/proto.h
@@ -1595,6 +1595,12 @@ uint16_t computeRIV(uint16_t N_RB_DL,uint16_t RBstart,uint16_t Lcrbs);
 
 uint32_t pmi_extend(LTE_DL_FRAME_PARMS *frame_parms,uint8_t wideband_pmi);
 
+int get_nCCE_offset_l1(int *CCE_table,
+		       const unsigned char L, 
+		       const int nCCE, 
+		       const int common_dci, 
+		       const unsigned short rnti, 
+		       const unsigned char subframe);
 
 uint16_t get_nCCE(uint8_t num_pdcch_symbols,LTE_DL_FRAME_PARMS *frame_parms,uint8_t mi);
 
diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c
index 3227be22b48968feb928efafcd3bab2172a2734f..bf01c2de9dc6e3ce908ab1cd5bd1182960afb614 100644
--- a/openair1/SIMULATION/LTE_PHY/dlsim.c
+++ b/openair1/SIMULATION/LTE_PHY/dlsim.c
@@ -266,15 +266,15 @@ int main(int argc, char **argv)
   unsigned int ret;
   unsigned int coded_bits_per_codeword=0,nsymb,dci_cnt,tbs=0;
 
-  unsigned int tx_lev=0,tx_lev_dB=0,trials,errs[4]= {0,0,0,0},errs2[4]= {0,0,0,0},round_trials[4]= {0,0,0,0},dci_errors=0,dlsch_active=0,num_layers;
-  int re_allocated;
+  unsigned int tx_lev=0,tx_lev_dB=0,trials,errs[4]= {0,0,0,0},errs2[4]= {0,0,0,0},round_trials[4]= {0,0,0,0},dci_errors=0,dlsch_active=0;//,num_layers;
+  //  int re_allocated;
   char fname[32],vname[32];
   FILE *bler_fd;
   char bler_fname[256];
   FILE *time_meas_fd;
   char time_meas_fname[256];
-  FILE *tikz_fd;
-  char tikz_fname[256];
+  //  FILE *tikz_fd;
+  //  char tikz_fname[256];
 
   FILE *input_trch_fd=NULL;
   unsigned char input_trch_file=0;
@@ -300,7 +300,7 @@ int main(int argc, char **argv)
   uint8_t rx_sample_offset = 0;
   //char stats_buffer[4096];
   //int len;
-  uint8_t num_rounds = 4,fix_rounds=0;
+  uint8_t num_rounds = 4;//,fix_rounds=0;
   uint8_t subframe=7;
   int u;
   int n=0;
@@ -314,8 +314,8 @@ int main(int argc, char **argv)
 
   // void *data;
   // int ii;
-  int bler;
-  double blerr[4],uncoded_ber,avg_ber;
+  //  int bler;
+  double blerr[4],uncoded_ber;//,avg_ber;
   short *uncoded_ber_bit=NULL;
   uint8_t N_RB_DL=25,osf=1;
   uint8_t fdd_flag = 0;
@@ -330,7 +330,7 @@ int main(int argc, char **argv)
   int common_flag=0,TPC=0;
 
   double cpu_freq_GHz;
-  time_stats_t ts;//,sts,usts;
+  //  time_stats_t ts;//,sts,usts;
   int avg_iter,iter_trials;
   int rballocset=0;
   int print_perf=0;
@@ -344,17 +344,22 @@ int main(int argc, char **argv)
   int TB0_active = 1;
   uint32_t perfect_ce = 0;
 
-  LTE_DL_UE_HARQ_t *dlsch0_ue_harq;
-  LTE_DL_eNB_HARQ_t *dlsch0_eNB_harq;
+  //  LTE_DL_UE_HARQ_t *dlsch0_ue_harq;
+  //  LTE_DL_eNB_HARQ_t *dlsch0_eNB_harq;
   uint8_t Kmimo;
   uint8_t ue_category=4;
   uint32_t Nsoft;
-  FILE    *proc_fd = NULL;
-  char buf[64];
+
+
+
+  int CCE_table[800];
 
   opp_enabled=1; // to enable the time meas
 
 #if defined(__arm__)
+  FILE    *proc_fd = NULL;
+  char buf[64];
+
   proc_fd = fopen("/sys/devices/system/cpu/cpu4/cpufreq/cpuinfo_cur_freq", "r");
   if(!proc_fd)
      printf("cannot open /sys/devices/system/cpu/cpu4/cpufreq/cpuinfo_cur_freq");
@@ -377,7 +382,7 @@ int main(int argc, char **argv)
   // default parameters
   n_frames = 1000;
   snr0 = 0;
-  num_layers = 1;
+  //  num_layers = 1;
   perfect_ce = 0;
 
   while ((c = getopt (argc, argv, "ahdpZDe:m:n:o:s:f:t:c:g:r:F:x:y:z:AM:N:I:i:O:R:S:C:T:b:u:U:v:w:B:PLl:Y")) != -1) {
@@ -1328,7 +1333,7 @@ int main(int argc, char **argv)
           dci_alloc[num_dci].L          = 1;
           dci_alloc[num_dci].rnti       = SI_RNTI;
           dci_alloc[num_dci].format     = format1A;
-          dci_alloc[num_dci].nCCE       = 0;
+          dci_alloc[num_dci].firstCCE       = 0;
           dump_dci(&PHY_vars_eNB->lte_frame_parms,&dci_alloc[num_dci]);
 
           printf("Generating dlsch params for user %d\n",k);
@@ -1635,7 +1640,7 @@ int main(int argc, char **argv)
           dci_alloc[num_dci].L          = 1;
           dci_alloc[num_dci].rnti       = SI_RNTI;
           dci_alloc[num_dci].format     = format1A;
-          dci_alloc[num_dci].nCCE       = 0;
+          dci_alloc[num_dci].firstCCE       = 0;
           dump_dci(&PHY_vars_eNB->lte_frame_parms,&dci_alloc[num_dci]);
 
           printf("Generating dlsch params for user %d\n",k);
@@ -1943,7 +1948,7 @@ int main(int argc, char **argv)
           dci_alloc[num_dci].L          = 1;
           dci_alloc[num_dci].rnti       = SI_RNTI;
           dci_alloc[num_dci].format     = format1A;
-          dci_alloc[num_dci].nCCE       = 0;
+          dci_alloc[num_dci].firstCCE       = 0;
           dump_dci(&PHY_vars_eNB->lte_frame_parms,&dci_alloc[num_dci]);
 
           printf("Generating dlsch params for user %d\n",k);
@@ -1974,7 +1979,7 @@ int main(int argc, char **argv)
         dci_alloc[num_dci].L          = 1;
         dci_alloc[num_dci].rnti       = n_rnti+k;
         dci_alloc[num_dci].format     = format1E_2A_M10PRB;
-        dci_alloc[num_dci].nCCE       = 4*k;
+        dci_alloc[num_dci].firstCCE       = 4*k;
         printf("Generating dlsch params for user %d\n",k);
         generate_eNB_dlsch_params_from_dci(0,
 					   subframe,
@@ -2019,17 +2024,20 @@ int main(int argc, char **argv)
     if (n_frames==1) printf("%d\n",numCCE);
 
     // apply RNTI-based nCCE allocation
+    memset(CCE_table,0,800*sizeof(int));
+
     for (i=num_common_dci; i<num_dci; i++) {
 
-      dci_alloc[i].nCCE = get_nCCE_offset(1<<dci_alloc[i].L,
-                                          numCCE,
-                                          (dci_alloc[i].rnti==SI_RNTI)? 1 : 0,
-                                          dci_alloc[i].rnti,
-                                          subframe);
+      dci_alloc[i].firstCCE = get_nCCE_offset_l1(CCE_table,
+						 1<<dci_alloc[i].L,
+						 numCCE,
+						 (dci_alloc[i].rnti==SI_RNTI)? 1 : 0,
+						 dci_alloc[i].rnti,
+						 subframe);
 
       if (n_frames==1)
         printf("dci %d: rnti %x, format %d : nCCE %d/%d\n",i,dci_alloc[i].rnti, dci_alloc[i].format,
-               dci_alloc[i].nCCE,numCCE);
+               dci_alloc[i].firstCCE,numCCE);
     }
 
     for (k=0; k<n_users; k++) {
@@ -2112,7 +2120,7 @@ int main(int argc, char **argv)
       round_trials[3] = 0;
 
       dci_errors=0;
-      avg_ber = 0;
+      //      avg_ber = 0;
 
       round=0;
       avg_iter = 0;
@@ -2697,13 +2705,13 @@ PMI_FEEDBACK:
               }
 
               start_meas(&PHY_vars_eNB->dlsch_modulation_stats);
-              re_allocated = dlsch_modulation(PHY_vars_eNB->lte_eNB_common_vars.txdataF[eNB_id],
-                                              AMP,
-                                              subframe,
-                                              &PHY_vars_eNB->lte_frame_parms,
-                                              num_pdcch_symbols,
-                                              PHY_vars_eNB->dlsch_eNB[k][0],
-                                              PHY_vars_eNB->dlsch_eNB[k][1]);
+              dlsch_modulation(PHY_vars_eNB->lte_eNB_common_vars.txdataF[eNB_id],
+			       AMP,
+			       subframe,
+			       &PHY_vars_eNB->lte_frame_parms,
+			       num_pdcch_symbols,
+			       PHY_vars_eNB->dlsch_eNB[k][0],
+			       PHY_vars_eNB->dlsch_eNB[k][1]);
               stop_meas(&PHY_vars_eNB->dlsch_modulation_stats);
               /*
               if (trials==0 && round==0)
diff --git a/openair1/SIMULATION/LTE_PHY/pdcchsim.c b/openair1/SIMULATION/LTE_PHY/pdcchsim.c
index caa7e1248d48e7dcc0078b45bffb1cb53f1d9d3c..f5e2fba8fc0f0d40394aeece372e297b5d7adfbc 100644
--- a/openair1/SIMULATION/LTE_PHY/pdcchsim.c
+++ b/openair1/SIMULATION/LTE_PHY/pdcchsim.c
@@ -56,7 +56,7 @@ PHY_VARS_UE *PHY_vars_UE;
 
 #define UL_RB_ALLOC 0x1ff;
 #define CCCH_RB_ALLOC computeRIV(PHY_vars_eNB->lte_frame_parms.N_RB_UL,0,2)
-#define DLSCH_RB_ALLOC 0x1fbf // igore DC component,RB13
+#define DLSCH_RB_ALLOC ((uint16_t)0x1fbf) // igore DC component,RB13
 
 void lte_param_init(unsigned char N_tx, unsigned char N_rx,unsigned char transmission_mode,unsigned char extended_prefix_flag,uint16_t Nid_cell,uint8_t tdd_config,uint8_t N_RB_DL,
                     lte_frame_type_t frame_type,uint8_t osf,uint32_t perfect_ce)
@@ -154,9 +154,9 @@ DCI_PDU DCI_pdu;
 
 DCI_PDU *get_dci(LTE_DL_FRAME_PARMS *lte_frame_parms,uint8_t log2L, uint8_t log2Lcommon, uint8_t format_selector, uint32_t rnti)
 {
-  uint8_t BCCH_alloc_pdu[8];
-  uint8_t DLSCH_alloc_pdu[8];
-  uint8_t UL_alloc_pdu[8];
+  uint32_t BCCH_alloc_pdu[2];
+  uint32_t DLSCH_alloc_pdu[2];
+  uint32_t UL_alloc_pdu[2];
 
   int i;
   int dci_length_bytes,dci_length;
@@ -462,31 +462,35 @@ DCI_PDU *get_dci(LTE_DL_FRAME_PARMS *lte_frame_parms,uint8_t log2L, uint8_t log2
   DCI_pdu.dci_alloc[0].ra_flag    = 0;
   memcpy((void*)&DCI_pdu.dci_alloc[0].dci_pdu[0], &BCCH_alloc_pdu[0], BCCH_pdu_size_bytes);
   DCI_pdu.Num_common_dci++;
-  /*
+  if (lte_frame_parms->N_RB_DL >= 25) {
   // add ue specific dci
-  DCI_pdu.dci_alloc[1].dci_length = dci_length;
-  DCI_pdu.dci_alloc[1].L          = log2L;
-  DCI_pdu.dci_alloc[1].rnti       = rnti;
-  DCI_pdu.dci_alloc[1].format     = format1;
-  DCI_pdu.dci_alloc[1].ra_flag    = 0;
-  memcpy((void*)&DCI_pdu.dci_alloc[1].dci_pdu[0], &DLSCH_alloc_pdu[0], dci_length_bytes);
-  DCI_pdu.Num_ue_spec_dci++;
-
-
-  DCI_pdu.dci_alloc[0].dci_length = UL_pdu_size_bits;
-  DCI_pdu.dci_alloc[0].L          = log2L;
-  DCI_pdu.dci_alloc[0].rnti       = rnti;
-  DCI_pdu.dci_alloc[0].format     = format0;
-  DCI_pdu.dci_alloc[0].ra_flag    = 0;
-  memcpy((void*)&DCI_pdu.dci_alloc[0].dci_pdu[0], &UL_alloc_pdu[0], UL_pdu_size_bytes);
-  DCI_pdu.Num_ue_spec_dci++;
-  */
+    DCI_pdu.dci_alloc[1].dci_length = dci_length;
+    DCI_pdu.dci_alloc[1].L          = log2L;
+    DCI_pdu.dci_alloc[1].rnti       = rnti;
+    DCI_pdu.dci_alloc[1].format     = format1;
+    DCI_pdu.dci_alloc[1].ra_flag    = 0;
+    memcpy((void*)&DCI_pdu.dci_alloc[1].dci_pdu[0], &DLSCH_alloc_pdu[0], dci_length_bytes);
+    DCI_pdu.Num_ue_spec_dci++;
+
+    if (lte_frame_parms->N_RB_DL >= 50) {
+      DCI_pdu.dci_alloc[2].dci_length = UL_pdu_size_bits;
+      DCI_pdu.dci_alloc[2].L          = log2L;
+      DCI_pdu.dci_alloc[2].rnti       = rnti;
+      DCI_pdu.dci_alloc[2].format     = format0;
+      DCI_pdu.dci_alloc[2].ra_flag    = 0;
+      memcpy((void*)&DCI_pdu.dci_alloc[0].dci_pdu[0], &UL_alloc_pdu[0], UL_pdu_size_bytes);
+      DCI_pdu.Num_ue_spec_dci++;
+    }
+  }
+
+
+
   DCI_pdu.nCCE = 0;
 
   for (i=0; i<DCI_pdu.Num_common_dci+DCI_pdu.Num_ue_spec_dci; i++) {
     DCI_pdu.nCCE += (1<<(DCI_pdu.dci_alloc[i].L));
   }
-
+  
   return(&DCI_pdu);
 }
 
@@ -523,10 +527,8 @@ int main(int argc, char **argv)
   uint8_t dci_cnt=0;
   LTE_DL_FRAME_PARMS *frame_parms;
   uint8_t log2L=2, log2Lcommon=2, format_selector=0;
-  uint8_t numCCE,nCCE_max,common_active=0,ul_active=0,dl_active=0;
-  uint32_t rv;
+  uint8_t numCCE,common_active=0,ul_active=0,dl_active=0;
 
-  DCI_format_t format = format1;
   uint32_t n_trials_common=0,n_trials_ul=0,n_trials_dl=0,false_detection_cnt=0;
   uint8_t common_rx,ul_rx,dl_rx;
   uint8_t tdd_config=3;
@@ -540,20 +542,20 @@ int main(int argc, char **argv)
 
   DCI_ALLOC_t dci_alloc_rx[8];
 
-  void* dlsch_pdu = NULL;
-  //  int ret;
+  int ret;
 
   uint8_t harq_pid;
   uint8_t phich_ACK;
 
   uint8_t num_phich_interf = 0;
   lte_frame_type_t frame_type=TDD;
-  int re_offset;
-  uint32_t *txptr;
+  //  int re_offset;
+  //  uint32_t *txptr;
   int aarx;
   int k;
   double BW=5.0;
   uint32_t perfect_ce = 0;
+  int CCE_table[800];
 
   number_of_cards = 1;
   openair_daq_vars.rx_rf_mode = 1;
@@ -894,7 +896,7 @@ int main(int argc, char **argv)
     i=0;
 
     while (!feof(input_fd)) {
-      fscanf(input_fd,"%s %s",input_val_str,input_val_str2);//&input_val1,&input_val2);
+      ret=fscanf(input_fd,"%s %s",input_val_str,input_val_str2);//&input_val1,&input_val2);
 
       if ((i%4)==0) {
         ((short*)txdata[0])[i/2] = (short)((1<<15)*strtod(input_val_str,NULL));
@@ -921,7 +923,7 @@ int main(int argc, char **argv)
 
   PHY_vars_UE->UE_mode[0] = PUSCH;
 
-  nCCE_max = get_nCCE(3,&PHY_vars_eNB->lte_frame_parms,get_mi(&PHY_vars_eNB->lte_frame_parms,0));
+  //  nCCE_max = get_nCCE(3,&PHY_vars_eNB->lte_frame_parms,get_mi(&PHY_vars_eNB->lte_frame_parms,0));
   //printf("nCCE_max %d\n",nCCE_max);
 
   //printf("num_phich interferers %d\n",num_phich_interf);
@@ -973,55 +975,62 @@ int main(int argc, char **argv)
         numCCE=0;
         n_trials_common++;
         common_active = 1;
-        n_trials_ul++;
-        ul_active = 1;
-        n_trials_dl++;
-        dl_active = 1;
+	if (PHY_vars_eNB->lte_frame_parms.N_RB_DL >= 50) { 
+	  n_trials_ul++;
+	  ul_active = 1;
+	}
+        if (PHY_vars_eNB->lte_frame_parms.N_RB_DL >= 25) { 
+	  n_trials_dl++;
+	  dl_active = 1; 
+	}
 
-        init_nCCE_table();
         num_pdcch_symbols = get_num_pdcch_symbols(DCI_pdu.Num_common_dci+DCI_pdu.Num_ue_spec_dci,
                             DCI_pdu.dci_alloc, frame_parms, subframe);
-        DCI_pdu.nCCE = get_nCCE(num_pdcch_symbols,&PHY_vars_eNB->lte_frame_parms,get_mi(&PHY_vars_eNB->lte_frame_parms,subframe));
+	numCCE = get_nCCE(num_pdcch_symbols,&PHY_vars_eNB->lte_frame_parms,get_mi(&PHY_vars_eNB->lte_frame_parms,subframe));
 
         if (n_frames==1) {
           printf("num_dci %d, num_pddch_symbols %d, nCCE %d\n",
                  DCI_pdu.Num_common_dci+DCI_pdu.Num_ue_spec_dci,
-                 num_pdcch_symbols,
-                 DCI_pdu.nCCE);
+                 num_pdcch_symbols,numCCE);
         }
 
         // apply RNTI-based nCCE allocation
+	memset(CCE_table,0,800*sizeof(int));
+
         for (i = 0; i < DCI_pdu.Num_common_dci + DCI_pdu.Num_ue_spec_dci; i++) {
           // SI RNTI
           if (DCI_pdu.dci_alloc[i].rnti == SI_RNTI) {
-            DCI_pdu.dci_alloc[i].nCCE = get_nCCE_offset(1<<DCI_pdu.dci_alloc[i].L,
-                                        DCI_pdu.nCCE,
-                                        1,
-                                        SI_RNTI,
-                                        subframe);
+            DCI_pdu.dci_alloc[i].firstCCE = get_nCCE_offset_l1(CCE_table,
+							       1<<DCI_pdu.dci_alloc[i].L,
+							       numCCE,
+							       1,
+							       SI_RNTI,
+							       subframe);
           }
           // RA RNTI
           else if (DCI_pdu.dci_alloc[i].ra_flag == 1) {
-            DCI_pdu.dci_alloc[i].nCCE = get_nCCE_offset(1<<DCI_pdu.dci_alloc[i].L,
-                                        DCI_pdu.nCCE,
-                                        1,
-                                        DCI_pdu.dci_alloc[i].rnti,
-                                        subframe);
+            DCI_pdu.dci_alloc[i].firstCCE = get_nCCE_offset_l1(CCE_table,
+							       1<<DCI_pdu.dci_alloc[i].L,
+							       numCCE,
+							       1,
+							       DCI_pdu.dci_alloc[i].rnti,
+							       subframe);
           }
           // C RNTI
           else {
-            DCI_pdu.dci_alloc[i].nCCE = get_nCCE_offset(1<<DCI_pdu.dci_alloc[i].L,
-                                        DCI_pdu.nCCE,
-                                        0,
-                                        DCI_pdu.dci_alloc[i].rnti,
-                                        subframe);
+            DCI_pdu.dci_alloc[i].firstCCE = get_nCCE_offset_l1(CCE_table,
+							       1<<DCI_pdu.dci_alloc[i].L,
+							       numCCE,
+							       0,
+							       DCI_pdu.dci_alloc[i].rnti,
+							       subframe);
           }
 
           if (n_frames==1)
             printf("dci %d: rnti 0x%x, format %d, L %d, nCCE %d/%d dci_length %d\n",i,DCI_pdu.dci_alloc[i].rnti, DCI_pdu.dci_alloc[i].format,
-                   DCI_pdu.dci_alloc[i].L, DCI_pdu.dci_alloc[i].nCCE, DCI_pdu.nCCE, DCI_pdu.dci_alloc[i].dci_length);
+                   DCI_pdu.dci_alloc[i].L, DCI_pdu.dci_alloc[i].firstCCE, numCCE, DCI_pdu.dci_alloc[i].dci_length);
 
-          if (DCI_pdu.dci_alloc[i].nCCE==-1)
+          if (DCI_pdu.dci_alloc[i].firstCCE==-1)
             exit(-1);
         }
 
@@ -1055,7 +1064,7 @@ int main(int argc, char **argv)
 
           generate_phich_top(PHY_vars_eNB,
                              subframe,AMP,0,0);
-          /*
+          
           // generate 3 interfering PHICH
           if (num_phich_interf>0) {
             PHY_vars_eNB->ulsch_eNB[0]->harq_processes[harq_pid]->first_rb = 4;
@@ -1082,7 +1091,7 @@ int main(int argc, char **argv)
           }
 
           PHY_vars_eNB->ulsch_eNB[0]->harq_processes[harq_pid]->first_rb = 0;
-          */
+          
         }
 
         //  write_output("pilotsF.m","rsF",txdataF[0],lte_PHY_vars_eNB->lte_frame_parms.ofdm_symbol_size,1,1);
@@ -1262,7 +1271,7 @@ int main(int argc, char **argv)
 
             for (i = 0; i < dci_cnt; i++)
               printf("dci %d: rnti 0x%x, format %d, L %d, nCCE %d/%d dci_length %d\n",i, dci_alloc_rx[i].rnti, dci_alloc_rx[i].format,
-                     dci_alloc_rx[i].L, dci_alloc_rx[i].nCCE, numCCE, dci_alloc_rx[i].dci_length);
+                     dci_alloc_rx[i].L, dci_alloc_rx[i].firstCCE, numCCE, dci_alloc_rx[i].dci_length);
           }
 
           for (i=0; i<dci_cnt; i++) {
@@ -1337,8 +1346,8 @@ int main(int argc, char **argv)
     } //trials
 
     printf("SNR %f : n_errors_common = %d/%d (%e)\n", SNR,n_errors_common,n_trials_common,(double)n_errors_common/n_trials_common);
-    printf("SNR %f : n_errors_ul = %d/%d (%e)\n", SNR,n_errors_ul,n_trials_ul,(double)n_errors_ul/n_trials_ul);
-    printf("SNR %f : n_errors_dl = %d/%d (%e)\n", SNR,n_errors_dl,n_trials_dl,(double)n_errors_dl/n_trials_dl);
+    if (ul_active==1) printf("SNR %f : n_errors_ul = %d/%d (%e)\n", SNR,n_errors_ul,n_trials_ul,(double)n_errors_ul/n_trials_ul);
+    if (dl_active==1) printf("SNR %f : n_errors_dl = %d/%d (%e)\n", SNR,n_errors_dl,n_trials_dl,(double)n_errors_dl/n_trials_dl);
     printf("SNR %f : n_errors_cfi = %d/%d (%e)\n", SNR,n_errors_cfi,trial,(double)n_errors_cfi/trial);
     printf("SNR %f : n_errors_hi = %d/%d (%e)\n", SNR,n_errors_hi,trial,(double)n_errors_hi/trial);
 
diff --git a/openair1/SIMULATION/LTE_PHY/ulsim.c b/openair1/SIMULATION/LTE_PHY/ulsim.c
index 134e6b28858aa3df5ad3a758415d7b967942cf6c..24e5c0fe7260af94c57755463ffe40e9c49ccace 100644
--- a/openair1/SIMULATION/LTE_PHY/ulsim.c
+++ b/openair1/SIMULATION/LTE_PHY/ulsim.c
@@ -74,7 +74,7 @@ extern short *ul_ref_sigs[30][2][33];
 PHY_VARS_eNB *PHY_vars_eNB;
 PHY_VARS_UE *PHY_vars_UE;
 
-#define MCS_COUNT 23//added for PHY abstraction
+//#define MCS_COUNT 23//added for PHY abstraction
 
 channel_desc_t *eNB2UE[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX];
 channel_desc_t *UE2eNB[NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX];
@@ -168,7 +168,7 @@ int main(int argc, char **argv)
 
   int aarx,aatx;
   double channelx,channely;
-  double sigma2, sigma2_dB=10,SNR,SNR2,snr0=-2.0,snr1,SNRmeas,rate,saving_bler;
+  double sigma2, sigma2_dB=10,SNR,SNR2,snr0=-2.0,snr1,SNRmeas,rate,saving_bler=0;
   double input_snr_step=.2,snr_int=30;
   double blerr;
 
@@ -199,7 +199,7 @@ int main(int argc, char **argv)
   unsigned int coded_bits_per_codeword,nsymb;
   int subframe=3;
   unsigned int tx_lev=0,tx_lev_dB,trials,errs[4]= {0,0,0,0},round_trials[4]= {0,0,0,0};
-  uint8_t transmission_mode=1,n_rx=1,n_tx=1;
+  uint8_t transmission_mode=1,n_rx=1;
 
   FILE *bler_fd=NULL;
   char bler_fname[512];
@@ -414,10 +414,6 @@ int main(int argc, char **argv)
         exit(-1);
       }
 
-      if (transmission_mode>1) {
-        n_tx = 1;
-      }
-
       break;
 
     case 'y':
@@ -701,8 +697,8 @@ int main(int argc, char **argv)
 
   // Create transport channel structures for 2 transport blocks (MIMO)
   for (i=0; i<2; i++) {
-    PHY_vars_eNB->dlsch_eNB[0][i] = new_eNB_dlsch(1,8,N_RB_DL,0);
-    PHY_vars_UE->dlsch_ue[0][i]  = new_ue_dlsch(1,8,MAX_TURBO_ITERATIONS,N_RB_DL,0);
+    PHY_vars_eNB->dlsch_eNB[0][i] = new_eNB_dlsch(1,8,1827072,N_RB_DL,0);
+    PHY_vars_UE->dlsch_ue[0][i]  = new_ue_dlsch(1,8,1827072,MAX_TURBO_ITERATIONS,N_RB_DL,0);
 
     if (!PHY_vars_eNB->dlsch_eNB[0][i]) {
       printf("Can't get eNB dlsch structures\n");
@@ -717,7 +713,7 @@ int main(int argc, char **argv)
     PHY_vars_eNB->dlsch_eNB[0][i]->rnti = 14;
     PHY_vars_UE->dlsch_ue[0][i]->rnti   = 14;
 
-  }
+  } 
 
 
   switch (PHY_vars_eNB->lte_frame_parms.N_RB_UL) {
@@ -905,11 +901,11 @@ int main(int argc, char **argv)
 
 
       harq_pid = subframe2harq_pid(&PHY_vars_UE->lte_frame_parms,PHY_vars_UE->frame_tx,subframe);
-
+      input_buffer_length = PHY_vars_UE->ulsch_ue[0]->harq_processes[harq_pid]->TBS/8;
+      input_buffer = (unsigned char *)malloc(input_buffer_length+4);
       //      printf("UL frame %d/subframe %d, harq_pid %d\n",PHY_vars_UE->frame,subframe,harq_pid);
       if (input_fdUL == NULL) {
-        input_buffer_length = PHY_vars_UE->ulsch_ue[0]->harq_processes[harq_pid]->TBS/8;
-        input_buffer = (unsigned char *)malloc(input_buffer_length+4);
+
 
         if (n_frames == 1) {
           trch_out_fdUL= fopen("ulsch_trchUL.txt","w");
@@ -931,7 +927,7 @@ int main(int argc, char **argv)
         i=0;
 
         while (!feof(input_fdUL)) {
-          fscanf(input_fdUL,"%s %s",input_val_str,input_val_str2);//&input_val1,&input_val2);
+          ret=fscanf(input_fdUL,"%s %s",input_val_str,input_val_str2);//&input_val1,&input_val2);
 
           if ((i%4)==0) {
             ((short*)txdata[0])[i/2] = (short)((1<<15)*strtod(input_val_str,NULL));
@@ -1261,6 +1257,7 @@ int main(int argc, char **argv)
           start_meas(&PHY_vars_eNB->phy_proc_rx);
           start_meas(&PHY_vars_eNB->ofdm_demod_stats);
           lte_eNB_I0_measurements(PHY_vars_eNB,
+				  subframe,
                                   0,
                                   1);
 
diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c
index 60e09503d3d9e607b436190b1f0217940732d4a3..21e9337dbb156425e9d5aa4600c75d0c337acf2b 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler.c
@@ -540,6 +540,7 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag,
 
   LOG_D(MAC,"FrameP %d, subframeP %d : Scheduling CCEs\n",frameP,subframeP);
 
+  // Allocate CCEs for good after scheduling is done
   for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++)
     allocate_CCEs(module_idP,CC_id,subframeP,0);
 
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
index 86f0f98d70b73fae621972f3e9c1d0fcab6dc1f8..332a0bd1de11d7e1ff5541ff6d21e0500df77165 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
@@ -543,7 +543,6 @@ schedule_ue_spec(
                     UE_list);
         // update UL DAI after DLSCH scheduling
         set_ul_DAI(module_idP,UE_id,CC_id,frameP,subframeP,frame_parms);
-
       }
 
       if (continue_flag == 1 ) {
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
index fadef3fbc801f07ee06bae3288dbccdc527a28ec..8880a85c2ee6bcfc598a6705c308ba81c0d17d27 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
@@ -1027,10 +1027,10 @@ int allocate_CCEs(int module_idP,
       }
       else { // number of CCEs left can potentially hold this allocation
 	if ((fCCE = get_nCCE_offset(CCE_table,
-				   1<<(dci_alloc->L), 
-				   nCCE_max,
-				   (i<DCI_pdu->Num_common_dci) ? 1 : 0, 
-				   dci_alloc->rnti, 
+				    1<<(dci_alloc->L), 
+				    nCCE_max,
+				    (i<DCI_pdu->Num_common_dci) ? 1 : 0, 
+				    dci_alloc->rnti, 
 				    subframeP))>=0) {// the allocation is feasible, rnti rule passes
 
 	  LOG_D(MAC,"Allocating at nCCE %d\n",fCCE);
diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c
index a5454e48f65373e50c3d38cf3bd03e5343cb45e5..e8264f31f6791b980cebb7c03e272318723a481a 100644
--- a/openair2/LAYER2/MAC/pre_processor.c
+++ b/openair2/LAYER2/MAC/pre_processor.c
@@ -762,6 +762,7 @@ void dlsch_scheduler_pre_processor_reset (int module_idP,
   ue_sched_ctl->dl_pow_off[CC_id] = 2;
   nb_rbs_required_remaining[CC_id][UE_id] = 0;
 
+  // Initialize Subbands according to VRB map
   for (i=0; i<N_RBG; i++) {
     ue_sched_ctl->rballoc_sub_UE[CC_id][UE_id] = 0;
     rballoc_sub[CC_id][i] = 0;