added session handling, ajax calls and and template blocks.