first pass at refactoring to support CSets