Refactor everything to use sets instead of raw keys