Added a session manager to handle exceptions and auth state.