Refactor window context for more general usage.