Make 'removeBuildTreeRefs' tolerate non-existing paths.

Fixes #1360.
Clarify what the arguments of 'mappendSomeSavedFlags' are.

Also add 'configProgramArgs' and 'configProgramPaths' to the set of
special-cased flags.