Fix broken session handling