Save only when needed and cleanup.