Code analisys improvements (Intellij Idea) part of JAMES-1220

* redundant code removal
* for-each transforamations
* 'final' attribute added
* Threadding issues solved - and still to be solved