Windows fix

Fix building on windows (and a little more).

Tested on windows, linux.