Redoing Algorithm #1 stage.

The last code had an Algorithm that contains several error that we
couldn't find. We are retyping and refactoring the algorithm to get rid
of the bugs. #1 Stage!