Use a proper immutable object to encapsulate the context state. Fix a precondition check to check the right variable.