 {
 	free(HostMem->Rd_xy);
 	free(HostMem->Tt_xy);
+	free(HostMem->time_xyt);
+	free(HostMem->tdet_pos_x);
+	free(HostMem->tdet_pos_y);
 	free(HostMem->fhd);
 	free(HostMem->thread_active);
 	free(HostMem->num_terminated_photons);

	if(HostMem->fhd==NULL){printf("Error allocating HostMem->fhd"); exit (1);}
	CUDA_SAFE_CALL( cudaMalloc((void**)&DeviceMem->fhd,fhd_size*sizeof(unsigned long long)) );
	CUDA_SAFE_CALL( cudaMemset(DeviceMem->fhd,0,fhd_size*sizeof(unsigned long long)) );

	// Allocate x and a on the device (For MWC RNG)
  CUDA_SAFE_CALL(cudaMalloc((void**)&DeviceMem->x,NUM_THREADS*sizeof(unsigned long long)));

	const int num_y=(int)(4*(sim->esp)*(double)sim->grid_size);
	const int num_z=(int)((sim->esp)*(double)sim->grid_size);
	const int fhd_size = num_x * num_y * num_z;

	const int num_x_tdet = sim->.det.x_temp_numdets;
  const int num_y_tdet = sim->.det.y_temp_numdets;
  const long num_tbins = sim->.det.temp_bins;
  const long timegrid_size = num_x_tdet * num_y_tdet * num_tbins;

	// Allocate p on the device
	CUDA_SAFE_CALL( cudaMalloc((void**)&DeviceMem->p,NUM_THREADS*sizeof(PhotonStruct)) );
