fix some bugs in the mem session manager