[WIP] Fixed some issues on Windows.

There are still multiple errors on Python 2, but many of them are probably follow-up issues failing with address already in use.