Fix state populating code