fixed session bug
some code cleaning