Refactor hashing and cleaning of attributes