fixed replacement events

* replace event now occurres 'after' rather than 'before' replacement
* beforeReplace has been added for before replacement
* replacing nodes no longer crashes the touch language