bug fixing in javascript and in templates.