small fixes

changed small things (for example all while loops that should have been
for loops)