Improved hash code calculations