reorganizing hash calculations (ahash, dhash)