Basic save state functionality, no loading.

Yep. This was me just adapting what was already there though.

Maybe you should have seen this on a previous PR, HA? ;)