Check for non-existent session in has_session
Preserve the order of windows