fix compiling errors and warnings in visual studio