Fix Windows, minor refactor