Corrections based on clang warnings

Clang compiler is generating far more warnings than any other compiler tested so far on our code. Some of them are trivial *i.e.* redundant semicolons or implicit type narrowing, and those were easy to avoid. Some other brought me to places, where codes intent is not clear.

Based on these warnings I propose to include this changes avoiding some of the warnings and making the code more straightforward in its intent.

Constructive criticizm is welcome!