added a base template and improved session handling