fixed encoding issue
end-of-session handling