Code improvements

Style fixes and some improvements (unnecessary loop, ...).

Is the last commit for today ... promised :)