polishing save/restore implementation