Fix some bugs with cross-platform