Reimplemented struct_hash to make it much faster