Changes to the organization of the algorithm
Some debugging