loading template 1st to have userenv set + fixing javasccript bug + reindenting