Refactor Session Handling