Fix a few issues, now correctly builds and links on Windows.