Adding support for persisting edits.

- removed some unsed code in the process.
- still need more test to be complete.