Fixed compile errors and warnings on windows