Bug 24366: Improve hashref construction