Merge "Switch AssertionErrors about being in a bad state to more-specific IllegalStateException"