Save state functionality

Could wrap these a bit shorter.