Fixes the implementation of clear_session