Make the state machine a little more generic.