made for/if/else constructs more consistent, some code polishing