Bugs fixes and and fully implement persistence