Invariants

Adds support for invariants which run at both the start and the end of a function.