Fixes for some clang static analysis warnings.
MSVC compile bug fix