Organized and brought in reusable code

Session.cpp has modified reusable code.