Clean up Reference class a bit.

* Fix some documentation errors.
* refactor Format function to avoid copying strings repeatedly with .Replace