Fix build warnings and errors for Vistual C++