Fixes for Windows compilation

Thanks to pluizer!