Refactor stylesheet-related functions into module
Refactor environment detection into module
Loading stylesheets into newly created windows improved