Change TOC to use a set, normalize filenames before storing, and clean up identifiers

Normalize case of all filenames added to TOC.
Use a set to enforce uniqueness of items added instead of a dictionary.
Implement subtract and intersect using set operations.
Rename many identifiers for clarity.

Fixes #1124 and supersedes PR #1123.