Small Javascript and template fixes