Adding some code from rewriting and DSELs lectures