Various fixes for cross-platform support