Refactor/sets for membership

Long time no see! :)  This is a small, focused pull request.  

Sets are better for membership tests, since they are unordered. These changes simply replace lists or tuples with sets for membership tests (order doesn’t matter).