Various build fixes

These will have to be tested with the build scripts on all platforms
And these.