Use an ordered dict to hold state