Fix MSVC build and few warnings

Now can be tested under MSVC