Initial refactoring to include extra state of windows. (Window now wraps WindowInfo)

Instead of using WindowInfo, some places now wrap it using Window,
allowing to store extra state which will be needed for a few subsequent
bug fixes.