Several improvements to handle anonymous users and sessions