clean up hash construction code in API