* cleanup: use for() instead of while to save lots of lines - and minor other stuff