Keep track of substitution events.

This addresses #10.