Added hash flipping to serialization and deserialization