avoid side effects in helper methods

Make the ivar assignment in the initializer so that subsequent calls to
the helper method will not mutate the instance.  Also, use map / uniq
rather than checking a hash key all the time.