Change DH_get_nid() to set the value of q if it is not already set