
73 Cal.Rptr.3d 469 (2008)
42 Cal.4th 1251
178 P.3d 446
In re David Woodrow SMITH, on Habeas Corpus.
No. S145959.
Supreme Court of California.
March 24, 2008.
*471 David Woodrow Smith, in pro. per.
J. Courtney Shevelson, under appointment by the Supreme Court, Carmel, for Petitioner David Woodrow Smith.
Steve Cooley, District Attorney, Lael Rubin, Brentford J. Ferreira, Phyllis C. Asayama and Rebecca Marie Madrid, Deputy *472 District Attorneys, for Respondent State of California.
*470 MORENO, J.
Under the Sexually Violent Predator Act (SVP Act), Welfare and Institutions Code section 6600 et seq., a person can be civilly committed as a sexually violent predator at the conclusion of a felony prison term, provided he or she has prior convictions for certain sexually violent offenses and a jury finds the person has a mental disorder that makes it likely he or she will engage in sexually violent criminal behavior. In the present case, after SVP commitment proceedings were initiated against petitioner, the felony conviction that was the basis of his custody at the time these proceedings were commenced was reversed by this court on appeal. (People v. Smith (2004) 32 Cal.4th 792, 796-799, 11 Cal.Rptr.3d 290, 86 P.3d 348 (Smith).) The prosecutor declined to retry him. The question this case poses is whether an SVP commitment can nonetheless proceed under these circumstances. In answering this question, we must construe language in section 6601, subdivision (a)(2), pr
oviding that an SVP petition "shall not be dismissed on the basis of a later judicial or administrative determination that the individual's custody was unlawful, if the unlawful custody was the result of a good faith mistake of fact or law."
We conclude that both the People and petitioner make reasonable arguments, based on the language and legislative history of the statutethe former that an SVP commitment is authorized under these circumstances, the latter that it is not. Based on substantial constitutional concerns, however, and the practice of construing statutes where reasonable to avoid difficult constitutional questions, we hold that an SVP commitment would not be authorized in these circumstances, and therefore reverse the Court of Appeal.

I. Factual and Procedural Background
The facts of this case are not in dispute. In 1982, Smith was convicted of four counts of oral copulation on a child under the age of 16 years (Pen.Code, § 288a, subd. (b)(2)) and one count of sodomy of a child under the age of 16 years (Pen.Code, § 286, subd. (b)(2)). In 1988,' Smith was convicted of 15 counts of committing lewd and lascivious acts on a child under the age of 14 years (Pen.Code, § 288, subd. (a).). Smith was released on parole in July 1995 and completed parole in July 1998.
As recounted in Smith, Smith was obligated to register as a sex offender because of his prior offenses. (Smith, supra, 32 Cal.4th at p. 795, 11 Cal.Rptr.3d 290, 86 P.3d 348.) In April 1999, Smith moved to Colorado from California; then, nine days later, he moved to New York. He claimed that he sent a change-of-address card to the Long Beach Police Department in a timely manner, but the officer responsible for sex offender registration testified that he did not receive any such card. When Smith did not appear in September 1999 to complete his annual registration, the Long Beach police began searching for him. Smith was arrested in New York. (Ibid.)
Convicted of failing to register as a sex offender (Pen.Code, § 290, former subd. (g)), Smith was sentenced to five years in state prison on October 26, 2000. (Smith, supra, 32 Cal.4th at pp. 796-797, 11 Cal. Rptr.3d 290, 86 P.3d 348.) The Court of Appeal affirmed his conviction on June 18, 2002. Smith petitioned for review of his conviction in this court, and we granted review on September 18, 2002.
While petitioner was awaiting resolution of his appeal in this court, he was referred to the State Department of Mental Health for evaluation as a possible SVP, pursuant *473 to Welfare and Institutions Code section 6601.[1] Two initial psychiatric evaluators disagreed on whether Smith met the SVP criteria, which triggered examination by two additional evaluators, who this time agreed that he did. On December 15, 2003, the Los Angeles County District Attorney filed a petition to have petitioner committed as an SVP. On March 2, 2004, petitioner was released from prison custody to the custody of the Los Angeles County Sheriffs Department on the basis of the pending SVP petition.[2]
On March 29, 2004, we reversed Smith's conviction. His defense had been that he sent the notification of change of address to the Long Beach police and it had been lost or not received through no fault of his own. We concluded the trial court committed reversible error by instructing a deadlocked jury, in response to a juror question, that a person subject to Penal Code section 290 has the obligation to ensure that notification of a change of address has been received by the police. (Smith, supra, 32 Cal.4th at pp. 796-799, 11 Cal.Rptr.3d 290, 86 P.3d 348.) The district attorney elected not to refile charges against Smith, who was already due to be released on parole by the time his conviction was reversed.
After his conviction was reversed, and before the SVP commitment proceedings progressed any further, petitioner filed a number of habeas corpus petitions challenging the continuation of these proceedings. On July 20, 2005, petitioner filed a habeas corpus petition in the Court of Appeal and that court issued an order to show cause. After briefing, oral argument, and supplemental briefing, the Court of Appeal issued an opinion denying petitioner relief. As elaborated below, the court rejected Smith's argument that the SVP Act did not authorize commitment once his most recent conviction had been reversed, and also rejected his argument that his continued commitment violated his rights to due process and equal protection. We granted Smith's petition for review.

II. Discussion

A. SVP Act
Before addressing the issue in the case, we first review the SVP Act. Under section 6601, subdivision (a)(1) (hereafter section 6601(a)(1)), "an individual who is in custody under the jurisdiction of the Department of Corrections, and who is either serving a determinate prison sentence or whose parole has been revoked," may be determined by the director of the department to be a potential SVP. An SVP was defined at the time of the relevant proceedings to be "a person who has been convicted of a sexually violent offense against two or more victims[3] and who has a diagnosed mental disorder that makes the person a danger to the health and safety of others in that it is likely that he or she will engage in sexually violent criminal behavior." (§ 6600, former subd. (a)(1), as amended, Stats.2000, ch. 643, § 1.) When a potential SVP is identified, "the director shall, at least six months prior to that individual's scheduled date for release *474 from prison, refer the person for evaluation in accordance with this section." (§ 6601(a)(1).) When this occurs, the potential SVP is referred to two mental health evaluators, who must agree that the individual has a diagnosed mental disorder and is likely to engage in acts of sexual violence absent appropriate treatment in custody. (§ 6601, subds. (b), (d), & (i).) A "`[d]iagnosed mental disorder' includes a congenital or acquired condition affecting the emotional or volitional capacity that predisposes the person to the commission of criminal sexual acts in a degree constituting the person a menace to the health and safety of others." (§ 6600, subd. (c).) Once two mental health evaluators agree that the person has a diagnosed mental disorder, and once the director has filed a petition, and the superior court has found probable cause, the individual has the right to counsel and to a jury trial. (§§ 6602, 6603; see People v. Superior Court (Ghilotti) (2002) 27 Cal.4th 888, 902-903, 119 Cal.Rptr.2d 1, 44 P.3d 949.)
Section 6601, subdivision (a)(2) (hereafter section 6601(a)(2)), provides that "[a] petition may be filed under this section if the individual was in custody pursuant to his or her determinate prison term, parole revocation term, or a hold placed pursuant to section 6601.3, at the time the petition is filed. A petition shall not be dismissed on the basis of a later judicial or administrative determination that the individual's custody was unlawful, if the unlawful custody was the result of a good faith mistake of fact or law." It is the meaning of the last sentence of this subdivision that is at issue in the present case.

B. Statutory Language
As Smith points out, and as the Court of Appeal acknowledged, the above-quoted subdivision refers to "unlawful custody" and not "unlawful conviction." Smith contends that section 6601(a)(2) refers to situations in which it later is determined that the potential SVP's custody was unlawful at the time the petition was filed because he or she should have been released earlier, and does not refer to situations like that in the present case, in which the conviction that is the basis of the potential SVP's custody at the time the petition is filed has been reversed.
Smith points to legislative findings contained in an uncodified portion of the statute that adopted section 6601(a)(2), which states that "where a petition for commitment of a sexually violent predator has been filed, it is not the intent of the Legislature that a person be released based upon a subsequent judicial or administrative finding that all or part of a determinate prison sentence, parole revocation term, or a hold placed pursuant to section 6601.3, was unlawful." (Stats.1999, ch. 136, § 3.) Smith argues that the Legislature's use of the term "sentence" is an indication that its focus was on the improper length of a sentence, not on a conviction being found unlawful. He contends that the reversal of a conviction is qualitatively different from a finding that a sentence was unlawful. "[A]ll ... of a ... sentence" could arguably refer to situations in which an entire sentence must be reversed and remanded because the sentencing court has proceeded improperly. (See, e.g., People v. Sandoval (2007) 41 Cal.4th 825, 858, 62 Cal.Rptr.3d 588, 161 P.3d 1146.)
This argument is not unreasonable. But the People reasonably counter that the Legislature's reference to "all or part" of a prison sentence is sufficiently broad to encompass reversal of a conviction, which would result in a determination that "all" of the resulting prison sentence is unlawful.
*475 There is somewhat stronger support for Smith's argument in the language of section 6604, which provides that if an individual subject to SVP proceedings is found by the trier of fact not to be an SVP, "the court shall direct that the person be released at the conclusion of the term for which he or she was initially sentenced, or that the person be unconditionally released at the end of parole, whichever is applicable." The above indicates that the Legislature envisioned the SVP Act to apply to someone serving his or her sentence to its conclusion, not someone earlier released because of a reversed conviction. This provision does not directly address the issue before us, however, and is far from conclusive on that issue.[4]
In sum, the statutory language of section 6601(a)(2) and the uncodified statutory language that accompanied its enactment is sufficiently broad to encompass the present situation of a reversed conviction, but it is unclear whether the Legislature meant to include unlawful conviction when it spoke of "unlawful custody." We turn then to the legislative history to clarify the Legislature's intention. (Nolan v. City of Anaheim (2004) 33 Cal.4th 335, 340, 14 Cal.Rptr.3d 857, 92 P.3d 350)

C. Legislative History
The legislative history indicates that section 6601(a)(2) was added in response to two Court of Appeal cases. In Terhune v. Superior Court (Whitley), (1998) 65 Cal. App.4th 864, 76 Cal.Rptr.2d 841 (Whitley I), the court considered the validity of a regulation that had been promulgated by the former Board of Prison Terms allowing parole to be revoked for psychiatric treatment when the parolee "`is suffering from a mental disorder which substantially impairs the parolee's ability to maintain himself or herself in the community, or which makes the parolee a danger to himself/herself or others, when necessary psychiatric treatment cannot be obtained in the community.'" (Id. at p. 868, 76 Cal. Rptr.2d 841.) In Whitley I, SVP proceedings were initiated against a prisoner, but the trial court dismissed the commitment petition for lack of probable cause. The board then used the above-quoted regulation to revoke his parole for 12 months of psychiatric treatment, and during this period, SVP proceedings were again initiated against him. (Whitley I, at pp. 870-872, 76 Cal.Rptr.2d 841.) The Court of Appeal in Whitley I held the regulation to be invalid, concluding in essence that it exceeded the board's authority, inasmuch as the regulation was a means of requiring felons who have served their sentence to remain in custody and receive involuntary treatment for reasons similar to those in the SVP or the Mentally Disordered Offenders Act (MDO Act; Pen.Code, § 2960 et seq.), but without providing the rigorous due process protections that these statutes require. (Whitley I, supra, 65 Cal.App.4th at pp. 878-880, 76 Cal.Rptr.2d 841.)
In the followup case of People v. Superior Court (Whitley) (1999) 68 Cal.App.4th 1383, 81 Cal.Rptr.2d 189 (Whitley II), the court was faced with the question of whether Whitley should be released because his parole had been revoked erroneously or remain subject to SVP proceedings. *476 The prisoner argued that the SVP Act can be applied only to those in custody for a conviction or parole revocation and he was not lawfully in custody on the revocation.
The Court of Appeal rejected Whitley's argument and ruled he remained subject to SVP proceedings. The Whitley II court considered People v. Dias (1985) 170 Cal. App.3d 756, 216 Cal.Rptr. 295 (Dias,) which held that although the Department of Corrections had filed a late petition to extend a prisoner's commitment under the former Mentally Disordered Sex Offender Act (MDSO Act; former § 6300 et seq.) due to an inadvertent miscalculation of the defendant's commitment term, the resulting commitment order was nonetheless valid. The Dias court concluded: "The record before us contains no hint of negligent or intentional wrongdoing by the persons charged with determining defendant's release date. The error resulted from a mistake of law on an issue where the relevant statute was not explicit and there was no controlling judicial decision directly on point. In this situation, we do not believe the error should be fatal to the extended commitment order. Given the evidence showing defendant continues to present a substantial danger of bodily harm to others, neither defendant nor the public would benefit by defendant's release at this time." (Dias, supra, 170 Cal.App.3d at p. 763, 216 Cal.Rptr. 295.)
The Whitley II court, drawing on Dias, then concluded: "The Legislature's stated purpose for the [SVP] Act was to identify dangerous sexually violent predators with diagnosable mental disorders while they are still incarcerated and to commit and treat those individuals as long as their disorders persist.... Consistent with that purpose, proceedings under the Act are initiated by the evaluation of inmates before their release from prison.... [11] ... [¶] ... As in Dias, the record in the present case does not indicate negligent or intentional wrongdoing by the Department of Corrections in revoking Whitley's parole for psychiatric conditions based on section 2616(a)(7). The department's error in revoking his parole on that basis resulted from its mistake of law concerning the scope of its broad statutory authority to establish and enforce regulations governing parole. Until we decided [Whitley I], there was ho controlling judicial decision directly on point.... Given these factors and in light of the serious public safety purpose underlying the Act, we conclude that despite the department's legal error, the trial court had jurisdiction or power to consider the People's latest petition for Whitley's commitment." (Whitley II, supra, 68 Cal.App.4th at pp. 1389-1390, 81 Cal.Rptr.2d 189.)[5]
When section 6601(a)(2) was added to the SVP Act in 1999, legislative committee analyses made clear that it was intended to adopt a rule similar to the holding in Whitley II. The Senate Committee on Public Safety's analysis of the amendment states that it was "a response to [Whitley I], in which the Court of Appeal barred SVP proceedings against inmate Whitley. [¶] In [Whitley II,] ... the court held that because [the Board of Prison Terms] and the [Department of Corrections] did not unlawfully hold Whitley in custody through `negligent or intentional wrongdoing,' an SVP petition against Whitley could proceed." (Sen. Com. on Public Safety, Analysis of Sen. Bill No. 11 (1999-2000 Reg. *477 Sess.) as amended Mar. 23, 1999, pp. 3-4.) As the analysis further states: "The issue that generated this bill arose in the context of a mistake of law about the application of psychiatric parole revocations as a means of holding an alleged SVP in custody at the time an SVP petition was filed. Such an error is arguably merely [a] technical error, as an inmate who appears to be an SVP would likely be subject to very rapid proper revocation of parole upon release from custody. Similar problems could arise if a court decision rules that good-faith sentencing credit calculations were made in error, [¶] The Attorney General, the co-sponsor of the bill, notes that this bill should also address analogous mistakes of fact. For example, a simple mistake in arithmetic in the calculation of credits could result in an untimely filing of an SVP petition. The Attorney General argues that such a good-faith error should not result in the release of [an] SVP who presents a substantial danger to the public." (Id. at pp. 5-6.)
This legislative purpose is reiterated in the Assembly appropriations committee's analysis: "According to the author and the sponsor, the Attorney General, this bill ensures that petitions to commit dangerous sex offenders to mental health facilities after their terms have expired cannot be dismissed simply because a judge found a prisoner's term was mistakenly extended. Correctional officials have had to release potential SVPs after an appellate court recently ruled that prisons could not detain mentally ill prisoners by revoking their parole prior to release." (Assem. Com. on Appropriations, Analysis of Sen. Bill No. 11 (1999-2000 Reg. Sess.) as amended Apr. 6,1999, pp. 1-2.)
An Assembly Republican bill analysis stated: "The bill responds to an ambiguity created by an appellate court decision and makes it clear that sexually violent predators are not to be unleashed on society simply because `the constable has blundered.' " (Assem. Com. on Public Safety, Republican Analysis of Sen. Bill No. 11 (1999-2000 Reg. Sess.) as amended Apr. 6, 1999, p. 1.)
Smith argues that the above legislative history strongly suggests that section 6601(a)(2) was intended to prevent errors that led to erroneous extensions of custody, including mistaken parole revocation. A reversed conviction, on the other hand, does not involve a mistaken extension of custody but rather an invalidation of the very judicial determination that had originally made the custody lawful. It rectifies prejudicial error that amounts to a miscarriage of justice. (People v. Garza (2005) 35 Cal.4th 866, 881, 28 Cal.Rptr.3d 335, 111 P.3d 310; Cal. Const., art. VI, § 13.) He contends that there is no indication from the legislative history that section 6601(a)(2) was intended to apply in these circumstances. Support for this position may be found in the Assembly Republican bill analysis quoted immediately above. If the purpose of the amendment was to make sure that potential SVP's do not go free simply because "the constable has blundered," then it would not apply to Smith, who would not be escaping SVP proceedings because of governmental error, but rather would be subject to these proceedings due to such error.
On the other hand, the People argue that Whitley II, which section 6601(a)(2) was intended to incorporate, goes beyond mere extensions of sentences and includes erroneous parole revocations, which are similar to an erroneous convictions. The People also point to the declared purpose behind the original SVP Act: "The Legislature finds and declares that a small but extremely dangerous group of sexually violent predators that have diagnosable mental disorders can be identified while they *478 are incarcerated. These persons are not safe to be at large and if released represent a danger to the health and safety of others in that they are likely to engage in acts of sexual violence. The Legislature further finds and declares that it is in the interest of society to identify these individuals prior to the expiration of their terms of imprisonment." (Stats.1995, ch. 763, § 1, p. 5921.) Given the broad concern for public safety central to the SVP Act, the People argue that section 6601(a)(2)'s broad language must be interpreted to extend to those who have been screened as SVP's while in prison, even when their present conviction is due to good-faith error.
We conclude that both sides advance reasonable interpretations of the statute. It appears to be the case that on the one hand, the Legislature did not expressly consider the situation of the person subject to SVP proceedings whose conviction is reversed, and that on the other hand, the Legislature intended for the SVP Act to sweep broadly and to conceivably extend to such persons. We need not decide, however, which statutory interpretation is more reasonable based on the statutory language and legislative history alone. As explained below, constitutional concerns favor Smith's construction of the statute.

C. The Equal Protection Clause and Section 6601(a)(2)
Smith argues that section 6601(a)(2), if construed as the People argues it should be, would violate the equal protection clause of the Fourteenth Amendment to the United States Constitution and its California equivalent. To determine the soundness of that position, we first review some basic principles:
"In resolving equal protection issues, the United States Supreme Court has used three levels of analysis. Distinctions in statutes that involve suspect classifications or touch upon fundamental interests are subject to strict scrutiny, and can be sustained only if they are necessary to achieve a compelling state interest. Classifications based on gender are subject to an intermediate level of review. But most legislation is tested only to determine if the challenged classification bears a rational relationship to a legitimate state purpose." (People v. Hofsheier (2006) 37 Cal.4th 1185, 1200, 39 Cal.Rptr.3d 821, 129 P.3d 29.)
Under California law, "`[s]trict scrutiny is the appropriate standard against which to measure [equal protection] claims of disparate treatment in civil commitment. [Citations.]'" (People v. Hubbart (2001) 88 Cal.App.4th 1202, 1217, 106 Cal.Rptr.2d 490.) This statement can be traced back to In re Moye (1978) 22 Cal.3d 457, 149 Cal.Rptr. 491, 584 P.2d 1097, a case involving a civil commitment under the MDSO Act, in which this court stated: "Because petitioner's personal liberty is at stake, the People concede that the applicable standard for measuring the validity of the statutory scheme now before us requires application of the strict scrutiny standard of equal protection analysis. Accordingly, the state must establish both that it has a `compelling interest' which justifies the challenged procedure and that the distinctions drawn by the procedure are necessary to further that interest. [Citation.] At the very least, persons similarly situated must receive like treatment under the law." (In re Moye, at pp. 465-166, 149 Cal.Rptr. 491, 584 P.2d 1097; see also Conservatorship of Hofferber (1980) 28 Cal.3d 161, 171, 167 Cal.Rptr. 854, 616 P.2d 836.)
The United States Supreme Court and this court have placed significant constitutional limitations, based on the equal protection clause, on the ability of the government *479 to distinguish between various types of civil committees. In Jackson v. Indiana (1972) 406 U.S. 715, 92 S.Ct. 1845, 32 L.Ed.2d 435 (Jackson,) Jackson was charged with two robberies, but was found to be incompetent to stand trial. Under Indiana law at the time, a criminal defendant could be civilly committed if found incompetent, and could be held in such commitment indefinitely. On the other hand, under Indiana's general civil commitment statutes, a mentally disordered person could be held in civil commitment only if he was a danger to others or in need of custodial care and treatment. The United States Supreme Court concluded that this double standard violated the equal protection clause. "[W]e hold that by subjecting Jackson to a more lenient commitment standard and to a more stringent standard of release than those generally applicable to all others not charged with offenses, and by thus condemning him in effect to permanent institutionalization without the showing required for commitment or the opportunity for release afforded by [Indiana's general civil commitment statutes], Indiana deprived petitioner of equal protection of the laws under the Fourteenth Amendment." (406 U.S. at p. 730, 92 S.Ct. 1845.)
In arriving at this conclusion, the court relied in part on Baxstrom v. Herold (1966) 383 U.S. 107, 86 S.Ct. 760, 15 L.Ed.2d 620, in which the court had held that it was a violation of equal protection to deprive a state prisoner of a jury trial and a finding of dangerousness when the state sought to civilly commit him at the end of his prison term, given that these protections were available to other persons civilly committed. As the Jackson court put it: "Baxstrom held that the State cannot withhold from a few the procedural protections or the substantive requirements for [civil] commitment that are available to all others." (Jackson, supra, 406 U.S. at p. 727, 92 S.Ct. 1845.) "Rejecting the State's argument that Baxstrom's conviction and sentence constituted adequate justification for the difference in procedures, the Court said that `there is no conceivable basis for distinguishing the commitment of a person who is nearing the end of a penal term from all other civil commitments.'" (Jackson, supra, 406 U.S. at p. 724, 92 S.Ct. 1845.) The Jackson court then concluded that "[i]f criminal conviction and imposition of sentence are insufficient to justify less procedural and substantive protection against indefinite commitment than that generally available to all others, the mere filing of criminal charges surely cannot suffice." (Ibid.)
We applied and clarified Jackson's holding in Conservatorship of Hofferber, supra, 28 Cal.3d 161, 167 Cal.Rptr. 854, 616 P.2d 836 (Hofferber.) As that opinion explained, California had a civil commitment statute for incompetent criminal defendants similar to the Indiana statute invalidated in Jackson. This court in In re Davis (1973) 8 Cal.3d 798, 106 Cal.Rptr. 178, 505 P.2d 1018 held that such individuals found to be incompetent to stand trial could be civilly committed only for a reasonable time for purposes of evaluation and recovery, after which they must either be released or subject to commitment as gravely disabled under California's general civil commitment statute, the Lanterman-Petris-Short Act (LPS Act). (§ 5000 et seq.) The definition of "gravely disabled" up to that point had been "a condition in which a person, as a result of a mental disorder, is unable to provide for his or her basic personal needs for food, clothing, or shelter." (§ 5008, former subd. (h)(1), as amended by Stats.1970, ch. 516, § 5, p. 1002; see now § 5008, subd. (h)(1)(A).) In response, the Legislature amended the definition of "gravely disabled," to permit a person to be found "gravely disabled" on *480 the additional grounds that he (1) is charged by indictment or information with a felony involving death, great bodily harm, or a serious threat to the physical well-being of another, and (2) is incompetent to assist in his defense because of a mental disorder. (§ 5008, former subd. (h)(2), as amended by Stats.1974, ch. 1511, § 12, p. 3321; see Hofferber, supra, 28 Cal.3d at p. 171, 167 Cal.Rptr. 854, 616 P.2d 836.) The petitioner in Hofferber contended that the new statutory scheme was a "transparent and unsuccessful evasion of Jackson and Davis." (Hofferber, at p. 170, 167 Cal.Rptr. 854, 616 P.2d 836.) Although agreeing in part with petitioner, the court opined that "we do not regard those cases as holding that the fact of criminal incompetency may never be a basis for involuntary confinement prescriptions." (Id. at p. 171, 167 Cal.Rptr. 854, 616 P.2d 836.)
We began the analysis in Hofferber with the observation that "[t]he state has compelling interests in public safety and in humane treatment of the mentally disturbed. [Citation.] It may adopt more than one procedure for isolating, treating, and restraining dangerous persons; and differences will be upheld if justified. [Citations.] Variation of the length and conditions of confinement, depending on degrees of danger reasonably perceived as to special classes of persons, is a valid exercise of state power. [¶] California laws have long followed that premise. For certain purposes they properly classify, separately, those mentally ill persons against whom a judicial determination of criminal conduct has been made since such persons, at least initially, have demonstrated particular danger. [Citations.]" (Hofferber, supra, 28 Cal.3d at pp. 171-172, 167 Cal. Rptr. 854, 616 P.2d 836; italics added, fn. omitted.)
We continued by surveying the various ways in which involuntary civil commitments may occur in this state: "The California scheme permits long-term, renewable commitments of persons found not guilty by reason of insanity (Pen.Code, § 1026 et seq.), mentally disordered sex offenders (MDSO's) (§ 6300 et seq.), and those committed to the Youth Authority (§ 1800 et seq.; People v. Smith (1971) 5 Cal.3d 313, 317, 96 Cal.Rptr. 13, 486 P.2d 1213)in each case on proof that they remain dangerously disturbed. On the other hand, violent persons not adjudicated under the criminal justice system are subject only to the short-term LPS Act procedure for `imminently dangerous' persons. They, unlike those criminally committed, may not be confined indefinitely on psychiatric opinion alone. (§§ 5300, 5304.)" (Hofferber, supra, 28 Cal.3d at p. 172, 167 Cal.Rptr. 854, 616 P.2d 836.)
This court explained the probable sources of such disparate treatment: "Those distinctions have two apparent bases. First, the Legislature apparently concluded that short-term civil confinement is preferable for most violent incidents caused by mental disturbance and that only seriously dangerous persons should be subject to the trauma and stigma of longer-term confinement. [Citation.] On the other hand, it was considered that acts serious enough for criminal treatment justify a continuing special interest in a person's nonpenal confinement for purposes of public safety. [Citations.] Weighing the compelling interest in avoiding confinement whenever possible against the equal need to protect society from the seriously dangerous mentally ill, the Legislature has naturally concluded that statutory distinctions must be made on the basis of degree of danger presented." (Hofferber, supra, 28 Cal.3d at pp. 172-173, 167 Cal.Rptr. 854, 616 P.2d 836, italics added.)
*481 We further clarified the high court's language in Jackson that "[i]f criminal conviction and imposition of sentence are insufficient to justify less procedural and substantive protection against indefinite commitment than that generally available to all others, the mere filing of criminal charges surely cannot suffice." (Jackson, supra, 406 U.S. at p. 724, 92 S.Ct: 1845.) We concluded that "[r]ead in context, Jackson stands only for the proposition that consideration of prior criminal conduct as a basis for distinguishing among dangerous persons must be reasonable." (Hofferber, supra, 28 Cal.3d at p. 173, fn. 10,167 Cal.Rptr. 854, 616 P.2d 836.)
Applying these principles, we reasoned that "separate treatment of permanently incompetent criminal defendants formally charged with violent felonies is justified. Allegedly they have engaged in violence so critical that serious criminal charges were believed appropriate. Magistrates or grand juries have found substantial evidence that the alleged conduct actually was committed as alleged. Those determinations of probable cause establish strong grounds to believe that, by concrete acts, the incompetent defendants already have seriously imperiled public safety and thus are particularly dangerous. Yet because of permanent incompetence they cannot be evaluated and confined for continuing dangerousness under the criminal processes usually applied to serious violent conduct." (Hofferber, supra, 28 Cal.3d at pp. 173-174,167 Cal.Rptr. 854, 616 P.2d 836.)
The Hofferber court nonetheless found section 5008, former subdivision (h)(2), constitutionally inadequate under equal protection because it did not impose a requirement of a finding beyond a reasonable doubt, after a hearing, that the person represented a current danger to others as a result of a mental disorder, as similar criminal insanity commitment statutes required, and implied such a requirement in order to render the statute constitutional. (Hofferber, supra, 28 Cal.3d at pp. 176-178,167 Cal.Rptr. 854, 616 P.2d 836.)
The basic principles of Jackson and Hofferber may be summarized as follows: (1) generally speaking, no individual or group when being civilly committed may be denied substantive or procedural protections that are provided to the population as a whole; (2) on the other hand, the Legislature may make reasonable distinctions between its civil commitment statutes based on a showing that the persons are not similarly situated, meaning that those who are reasonably determined to represent a greater danger may be treated differently from the general population; (3) in particular, those who are criminally convicted, and those indicted of criminal charges but incompetent to stand trial, may be distinguished, at least initially, from the general population for civil commitment purposes, because their criminal acts demonstrate that they potentially pose a greater danger to society than those not in the criminal justice system.
With these principles in mind, we consider whether Smith in the present case is being treated differently from those who are subject to our state's general civil commitment statute, the LPS Act, and, if so, whether that differential treatment is reasonable. We begin this inquiry with a brief review of the LPS Act.
"The LPS Act `"limits involuntary commitment to successive periods of increasingly longer duration, beginning with a 72hour detention for evaluation and treatment ([Welf. & InstCode,] § 5150), which may be extended by certification for 14 days of intensive treatment"([Welf. & Inst. Code,] § 5250); that initial period may be extended for an additional 14 days if the person detained is suicidal. ([Welf. & Inst.Code,] § 5260.) ... [T]he 14-day *482 certification may be extended for an additional 30-day period for further intensive treatment. ([Welf. & InstCode,] § 5270.15.) Persons found to be imminently dangerous may be involuntarily committed for up to 180 days beyond the 14-day period. ([Welf. & InstCode,] § 5300.) After the initial 72-hour detention, the 14day and 30-day commitments each require a certification hearing before an appointed hearing officer to determine probable cause for confinement unless the detainee has filed a petition for the writ of habeas corpus. ([Welf. & InstCode,] §§ 5256, 5256.1, 5262, 5270.15, 5275, 5276.) A 180-day commitment requires a superior court order. ([Welf. & InstCode,] § 5301.)'"" (People v, Allen (2007) 42 Cal.4th 91, 106-107, 64 Cal.Rptr.3d 124, 164 P.3d 557.)
The LPS Act provides that longer-term civil commitment will be authorized only after a rigorous showing. In order to be subject to the initial 72-hour, 14-day, and 30-day commitments, an individual must be found to be either a danger to self or others or gravely disabled, initially according to the observations of a peace officer or other designated professional (§ 5150) and later by the observations of the professional staff of the agency or treating facility (§§ 5260, 5270.15). In order to receive the 180-day commitment under the LPS Act, as one court has summarized it, a person, "`as a result of mental disorder or mental defect, [must] present[ ] a demonstrated danger of inflicting substantial physical harm upon others'; and must have attempted, inflicted, or made a serious threat of substantial physical harm upon another after having been taken into custody for evaluation and treatment, or must have attempted or inflicted physical harm upon another and that act resulted in his being taken into custody, or must have expressed a serious threat of substantial physical harm upon another within seven days of being taken into custody and that threat at least in part resulted in his being taken into custody. (§§ 5300, subds. (a)-(c), 5304, subd. (a)(1), (2), (3).)" (People v. Buffington (1999) 74 Cal.App.4th 1149, 1161-1162, 88 Cal.Rptr.2d 696, italics and underscoring omitted.) In order to be subject to renewable one-year conservatorships under the LPS Act, one must be found to be gravely disabled either by being manifestly unable to take care of oneself or being in custody on a criminal charge and found incompetent to stand trial and having a mental disorder causing one to be dangerous to others. (§§ 5350, 5008, subd. (h), 5361; see People v. Karriker (2007) 149 Cal.App.4th 763, 774-775, 57 Cal.Rptr.3d 412.)
As discussed above, under the SVP Act those currently in prison with the requisite convictions for sexually violent offenses can be subject to continued civil commitment solely on the basis of findings that an individual has a mental disorder that makes it likely he or she will engage in sexually violent criminal behavior. (§§ 6601-6604.) On the other hand, those not in prison, including those who also have prior convictions for sexually violent offenses, can be subject to long-term civil commitment only when, as explained, they are determined to be gravely disabled or to have a mental disorder and to be a danger to self and others as shown by recent acts. Stated another way, a person convicted of prior sexual offenses who is currently not in prison, and who has not done anything to manifest grave disability or recent dangerousness based on mental disorder, may not be civilly committed in California.
We have no doubt that such a distinction between those who are and are not in prison custody, in general, passes muster under the equal protection clause. As discussed, the Legislature may separately *483 classify "mentally ill persons against whom a judicial determination of criminal conduct has been made since such persons, at least initially, have demonstrated particular danger." (Hofferber, supra, 28 Cal.3d at p. 172, 167 Cal.Rptr. 854, 616 P.2d 836.) Although Hofferber's pronouncement was made in the context of violent criminal conduct, the Legislature could legitimately conclude in the context of the SVP Act that any felonious criminal conduct would warrant a finding of greater danger and a separate classification. Individuals in prison with felony convictions have yet to demonstrate their capacity or willingness to keep their conduct within the bounds of the law and to break old criminal habits, and the Legislature could legitimately conclude that such felons who have prior sexually violent offenses represent a particular danger to society that justifies a separate system of civil commitment. Such a conclusion would be an extension of the basic principle underlying our parole system that those newly released from prison, who have not yet proven their ability to be lawabiding citizens, deserve particular scrutiny. (See Cohen, The Law of Parole & Probation (2d ed.2000) § 1.20, p. 1-29.)
But the justification for differential treatment is less clear when, as here, the conviction that was the basis of prison custody has been reversed. In terms of potential dangerousness, a person whose felony conviction has been reversed is in the same position as someone who was charged with, but not convicted of, a felony offense, yet it is undisputed that the latter could not be subject to SVP proceedings. Nor does it appear that those whose convictions were reversed relatively early in their prison term, before SVP proceedings were commenced, could be subject to such proceedingsection 6601(a)(2) by its plain terms applies to prevent dismissal of petitions already filed, not the initiation of new petitions.
It is true that Smith in the present case was the subject of a preliminary determination by mental health professionals that he may be an SVP. But that distinction does not appear to be decisive. A person who has had the same criminal history as Smith, and who, for whatever reason, becomes civilly rather than criminally committed, will be subject to intensive psychiatric evaluation to determine whether as a result of a mental disorder he is a danger to others. (See §§ 5213, subd. (a), 5250, subd. (a), 5300.) During this evaluation, mental health professionals may well conclude that the individual has a diagnosis substantially similar to Smith's in the present case, or they may make other predictions about his future dangerousness. But as discussed above, under the LPS Act, those diagnoses and predictions alone cannot be the basis of an extended civil commitment. One could be subject to such commitment only on the basis of a finding of grave disability or recent dangerousness, as discussed above. It is only Smith's status as a prisoner that makes him eligible for continued civil commitment based on past criminal history and diagnoses and predictions of future dangerousness alone. That differential treatment is justifiable in equal protection terms if Smith's most recent conviction were valid. It is not clear such treatment is justifiable when that conviction is reversed. (See Hofferber, supra, 28 Cal.3d at p. 172, 167 Cal.Rptr. 854, 616 P.2d 836.)
Our common practice is to "construct ] statutes, when reasonable, to avoid difficult constitutional questions." (he Francois v. Goel (2005) 35 Cal.4th 1094, 1105, 29 Cal.Rptr.3d 249, 112 P.3d 636.) Consistent with that practice, we construe section 6601(a)(2) not to apply to someone in Smith's position, whose conviction that *484 was the basis of his prison custody at the time SVP proceedings were initiated has been reversed, and who has not been retried and reconvicted.
Such a construction would still allow the state to proceed against those whose initial prison custody was valid, but who might evade SVP commitment due to erroneous parole revocations or extensions of sentence, the groups of prisoners against whom section 6601(a)(2) was targeted. (See, e.g., Whitley II, supra, 68 Cal. App.4th 1383, 81 Cal.Rptr.2d 189; Garcetti v. Superior Court (Lyles), supra, 68 Cal. App.4th 1105, 80 Cal.Rptr.2d 724; People v. Wakefield, supra, 81 Cal.App.4th 893, 97 Cal.Rptr.2d 221.) Subjecting these classes of prisoners to SVP proceedings does not raise the equal protection problems discussed in the present case. It is certainly justifiable in equal protection terms, for the reasons discussed above, to treat convicted prisoners differently for purposes of civil commitment from the general population, even when those prisoners stand to evade the statutory time limits for initiating SVP proceedings due to good-faith factual or legal error. Moreover, a prisoner on parole remains in constructive custody (Pen.Code, § 3056; see 3 Witkin & Epstein, Cal.Criminal Law (3d ed. 2000) Punishment, § 631, pp. 828-829), and is not similarly situated, for purposes of the equal protection issue posed by this case, to a prisoner whose conviction that was the basis of his or her custody is reversed due to prejudicial error. Our present holding would affect only those in Smith's unusual circumstances, i.e., a prisoner who has obtained an appellate reversal of his conviction late in his prison term after an SVP petition has been filed, and who has not been retried and reconvicted.
As the above implies, our holding means that if the People seek to continue SVP proceedings against someone whose present conviction has been reversed, it must retry and reconvict him. We regret that this requirement imposes an additional burden on the People, particularly when the person has already served his prison sentence. We interpret the statutory scheme to impose this burden due to the constitutional concerns articulated above.[6]
We emphasize that we agree with the People that the state has a compelling interest in timely initiating SVP proceedings for prisoners who appear to be eligible for SVP commitment. Nothing we say in the present opinion should be interpreted as requiring the responsible authorities to wait until a defendant has exhausted his appeals before initiating SVP proceedings against him.[7] Nor do we foreclose the possibility that the Legislature could amend the SVP Act so that it would constitutionally apply to someone in Smith's position. We hold only that, in light of the *485 constitutional concerns discussed above, we do not construe the statute as currently written to so apply.

III. Disposition
The judgment of the Court of Appeal is reversed and the cause is remanded with directions to grant Smith's petition for a writ of habeas corpus.
WE CONCUR: GEORGE, C.J., KENNARD, BAXTER, WERDEGAR, CHIN and CORRIGAN, JJ.
NOTES
[1]  All statutory references are to this code unless otherwise indicated.
[2]  The briefing discloses that Smith was due to be released on parole on January 1, 2004. He remained in custody at the California Men's Colony in San Luis Obispo in order to undergo throat cancer treatment until March 2, 2004, when he was transferred to the Los Angeles County jail under authority of the pending SVP petition.
[3]  The SVP Act was amended by initiative on November 7, 2006, to redefine an SVP as a person convicted of a sexually violent offense against "one or more victims...." (§ 6600, subd. (a)(1), as amended by initiative measure (Prop. 83, § 24), Nov. 7, 2006, italics added.)
[4]  Smith also argues that allowing him to be subject to SVP commitment would violate Penal Code section 1180. Section 1180 states in full: "The granting of a new trial places the parties in the same position as if no trial had been had. All the testimony must be produced anew, and the former verdict or finding cannot be used or referred to, either in evidence or in argument, or be pleaded in bar of any conviction which might have been had under the accusatory pleading." The People are correct, however, that the focus of that statute is on subsequent criminal proceedings.
[5]  Another Court of Appeal case decided around the same time as Whitley II came to the same conclusion. (Garcetti v. Superior Court (Lyles) (1999) 68 Cal.App.4th 1105, 80 Cal.Rptr.2d 724; see also People v. Wakefield (2000) 81 Cal.App.4th 893, 97 Cal.Rptr.2d 221.)
[6]  Should this situation arise again, we make clear that once an SVP petition has been properly filed, a reversal of the conviction that is the basis of prison custody is not by itself grounds for dismissing the petition. If the People timely elect to retry, then proceedings may be stayed pending the outcome of the retrial, but nothing in the statute or the equal protection clause requires dismissal of the petition. Only when the People do not timely elect to retry, or when the person is not convicted on retrial, is the petition subject to dismissal. If the person is reconvicted on retrial, then SVP proceedings may be reinstated.
[7]  Moreover, it is possible a person who is not eligible for SVP commitment because of a reversed conviction may still qualify for other forms of civil commitment. (See People v. Allen, supra, 42 Cal.4th 91, 105-108, 64 Cal. Rptr.3d 124, 164 P.3d 557 [individual no longer eligible for commitment under MDO Act may be committed if eligible under the LPS Act].)
