Refactoring window mgmt and persistence