osx-window code refactor largely