Working version with saving, restoring.