Replacing and restoring function globals during 'solve'