Fixed some repeated code that makes it impossible to break out of a session