Cleaned up sessions and authentications code.