session code cleanup