Refactored code to have global session store for server