Several fixes for windows build