Replace session variables where possible