Changed the way URLs are generated in templates to be a bit safer.