Save and restore variables