Added saving and loading state to/from file.