Add save state functionality.