Add invariant specs, fix build