refactor source: optimize session manager