Fixes bug with opening new sessions.

New sessions would not open after ending an existing
one due to a fault in refreshSessions. See commit 
message for more details on the fix.