Rehash number of buckets too, this speeds up things a bit. Use a vector of bools for the visited map