Fix an error related to rewriting session