void hectate_fiber_body(FiberManager *my_manager) {
  Context context(my_manager);
  context.setRoot(setup_root());
  my_context = &context;
  
  auto arg = my_manager->getArgs();

  run_file("./init.h6x", context, false);
  
  for (int i = 1; i < arg.argc; i++) {
    if (strcmp(arg.argv[i], "-") == 0) {
      REPL(context);
    }
    else {
      run_file(arg.argv[i], context);
    }
  }

  if (arg.argc <= 1) {
    //have no args
    REPL(context);
  }
  
}
int main(int argc, const char *argv[])
{
  float increment_x, increment_y;
  int pixel_x = 512, pixel_y = 512, it;
  unsigned int rpp = 500;
  int ncells = 4;
  float accuracy = 0.6;
  count = 0;
  root = NULL;
  curr = NULL;
  
  // Load relevant settings and data
  if (argc < 2) error("Requires argument with lens positions and optional mass");
  setup_constants();
  read_lenses(argv[1]);
  
  setup_root(-lens_rad, lens_rad, lens_rad, -lens_rad, ncells);
  
  build_tree(ncells, root);
  calculate_cm(root, ncells);

  //printf("All cells\n");
  //printf("index, centre mass x, centre mass y, total mass\n"); 
  remove_empty_cells(root, ncells);
  //print_tree(root, ncells);

  fprintf(stderr, "X %f and Y %f\n", image_scale_x, image_scale_y);
  increment_x = (image_scale_x * 2) / pixel_x;
  increment_y = (image_scale_y * 2) / pixel_y;
  fprintf(stderr, "Increments for X %f and Y %f\n", increment_x, increment_y);

  unsigned int *results = (int *)calloc(pixel_x * pixel_y, sizeof(unsigned int));
  if (!results) error("calloc failed in allocating the result array");
  int highest = 0;

  // Fire off the light rays and record their end locations
  int complete_iterations = 0;
  //#pragma omp parallel for
  for(it = 0; it < rpp; ++it) {
    float x, y, dx, dy;
    for(y = -image_scale_y; y < image_scale_y; y += increment_y) {
      for(x = -image_scale_x; x < image_scale_x; x += increment_x) {
        // Noise is uniformly distributed -- i.e. it's not really noise
        float noise_x = it * increment_x / rpp;
        float noise_y = it * increment_y / rpp;
        dx = x + noise_x;
        dy = y + noise_y;
        
        count_included_bodies(root, accuracy, dx, dy);
        cells = (cell *)malloc(sizeof(cell) * count);
        count = 0;
        get_included_bodies(root, accuracy, dx, dy);
        
        deflect(&dx, &dy);
        // Source plan (where collected) is -source_scale/2 to source_scale/2
        if ((dx > -source_scale/2) && (dx < source_scale/2) &&
            (dy > -source_scale/2) && (dy < source_scale/2)) {
          // Work out the nearest pixel to put this in to
          // Add to remove the negative part of source_scale and then source_scale / pixels
          int px = (dx + source_scale/2) / (source_scale/pixel_x);
          int py = source_scale/ (source_scale/pixel_y) - (dy + source_scale/2) / (source_scale/pixel_y);
          results[py * pixel_x + px] += 1;
          if (results[py * pixel_x + px] > highest) highest = results[py * pixel_x + px];
        }
        count = 0;
        free(cells);
		cells = NULL;
      }
    }
     	fprintf(stderr, "\r%4d/%4d Complete\r", ++complete_iterations, rpp);
  }
  assert(highest > 0 && "No pixels were written on the output map");
  write_pgm(results, pixel_x, pixel_y, highest);
  
  // Free the memory allocated during processing
  free(lens_x);
  free(lens_y);
  free(lens_mass);
  free(results);
  free(curr);

  return 0;
}