Keeping session ID; some refactoring