fix some cross-platform compatibility issues