Some windows fixes

I wasn't sure what to do with the code in the second commit.