Code beautification + cookie bugfix

Made the code a little more cleaner to read and fixed a cookie expiration bug which happened with non-default sesion cookie params.