Made some patches to fix windows build