Deduplicate permanent state.
Add append optimization.