Keep track of substitution events.

This addresses #4.