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

Works for the application I am building, but probably needs more testing. Note that OrderedDict does not support the insert operation, so it can't be used here.

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.