Refactor so that windows can be used within a process as a library