Added the ability to save and load states