Apply PSR-2 coding styleguide to source code
Some code quality improvements.
Fixed a lot of code inspection issues with documentation, unreachable code,
and so on and so on.
This is just one part of improvements. More will follow soon