Use hashes instead of in_array lookups