small refactoring, cast session restore (part)