Split load/save state into their own functions.