Cleanup variable name, add restoration of format (bug #3759, with mods)