Working interations summation and calculation.
Code cleanup.
Adds the third dimension.