Fix Windows build and a few more problems