Fixes for session cleanup