Windows build improvements

Various fixes to improve linker issues when building on windows.