some improvements

I made some improvements, and fixed a bug with session expiring.