fixed some bugs when creating a session