fix bad programming for hash, add statistics