Implemented persistence

Added persistence and example to show how it works.