Smarter hash serialization