Fix contract state updating