Refactor session_filter.