fixed session mgt and added hooks