Deleting old code, a few comments, rename i->betasegments for clarity.