Refactor form state storage