Refactor for Windows support