Escape fixes

- Clean up some potential places to cause mischief need to have their inputs escaped. Use underscore, uTemplates to do the escaping.
- Clean up some repetitive log statements
- Clean up some fragile string concatenation