Performance improvements

- do not pass compact value if it is the same as a regular value
- do not perform html escaping on the same string twice