Some patches for windows support