Updated Invariant Check Code.