Improved the code, added persistant storage.