Ensure state keys are defined before they are used.