Fix some bugs for new session