Fix MSVC build and few warnings