Optimize from set -> int variables when possible.