Refactor Windows code