Dev2.1

Fixing Issue #71 by converting the "for" loop to a "while" loop and eliminating val constructors inside the loop.
Some formatting changes that occurred while editing code.