Cleanup replaceTokens

* Allowed both the `$...$` syntax and the `${...}` bash syntax
* Removed by reference stuff, it's not needed.
* Introduced a cleaner way of replacing by using `preg_replace_callback`