Tighten up the save/restore procedure for get_from_file and get_from_string.

This makes it fully reliable if called in a nested fashion.