fixed bug in the session cleaning code