Various Windows compilation fixes