fix build error on windows and some warnings