Added some persistance stuff, but still buggy