Refactor window operator and state manager.