Optimized hashing class.