Added `invariant`s, though not yet working right.