Fix compile errors on win32, warnings elsewhere