Loop changed to directly calculate bit-shifts; uses the bit-shifted value to loop.

Some more debug output changes.