refined sessions handling and templates