ENH: memory robust to modification of source files

This is a takeover of PR #131. See description for details.