fix session destory bug, code improvements