Win port

I found a way to throw away the previous kludges in my earlier pull request in favor of this more streamlined approach.