fix bugs with IDs.
Add basic peristence support