Fixed bugs in the calculation of the start and end of the expansion'