weekly code cleanup

weekly code cleanup - fix some warnings found by MSVC, ICC, CppCheck,
also few errors found by stress testing. generic cosmetic changes.