Refactor save state support. Added a run() method.