Fix state restoration in reload

Fix #5198