
699 P.2d 875 (1985)
S.N.E., Appellant,
v.
R.L.B., Appellee.
No. S-426.
Supreme Court of Alaska.
May 10, 1985.
*877 Charlene A. Lichtman, Sandra K. Saville, Kay, Christie, Saville & Coffey, Anchorage, for appellant.
Robert H. Wagstaff, Anchorage, for appellee.
Vincent Vitale, Law Offices of Vincent Vitale, Anchorage, Guardian Ad Litem.
Before RABINOWITZ, C.J., and BURKE, MATTHEWS, COMPTON and MOORE, JJ.

OPINION
COMPTON, Justice.
Father (R.L.B.) moved in superior court for an order changing custody of a minor child from Mother (S.N.E.) to Father. After extensive hearings, the superior court entered an order granting Father's motion. Mother appeals. For the reasons hereafter set forth, we reverse.

I. FACTUAL AND PROCEDURAL BACKGROUND
Father is 34 years old. After a prior marriage ended in a divorce, Father met and then began living with Mother. After one and a half years, they married, but three months later they divorced. Mother was pregnant at the time of the marriage and divorce. Following this divorce, Father again remarried. Mother gave birth to the child four months after the divorce.
Mother is 33 years old. She, too, had been married before she met Father. She is presently a graduate student on leave from her regular employment. She is a lesbian, now living in Washington with a female companion. Father knew of Mother's sexual ambivalence when they married.
Mother and Father entered a child custody agreement at the time of the divorce, naming Mother primary custodian and granting Father reasonable visitation rights. The question of the best interests of the child was not litigated at that time, since the child was still in utero.
Three years after signing the custody agreement, Father moved for a change of legal custody in the best interests of the child, contending that Mother was a lesbian with radical political views, that she was emotionally unstable, and that he was in fact the child's primary parent and custodian. The superior court awarded custody to Father.

II. CUSTODY AWARD STANDARD
The best interests of the child control the outcome of all child custody disputes.[1]
The precise legal standard to be applied by the court depends on whether the dispute arises out of an initial placement or a modification of a prior custody order. The Family Law Act requires the court to consider six factors when making initial custody placements. AS 25.24.150(c). In contrast, when one party seeks a change in custody, a court must consider whether there are changed circumstances which justify modifying a prior custody order.[2]
Here there is no question of according due deference to a prior judicial determination of the best interests of the child, since Mother and Father entered a voluntary custody agreement at the time of the divorce, while Mother was still pregnant. *878 However, in King v. King, 477 P.2d 356 (Alaska 1970), we applied the changed circumstances doctrine in modifying a custody award entered in an uncontested divorce. Furthermore, we have repeatedly stated our concern with maintaining continuity of care and avoiding disturbing and upsetting the child with repeated custody changes. Gratrix v. Gratrix, 652 P.2d 76, 81 (Alaska 1982); Morel v. Morel, 647 P.2d 605, 608 (Alaska 1982); Starkweather v. Curritt, 636 P.2d 1181, 1183 n. 1 (Alaska 1981).
We therefore hold that the changed circumstances doctrine applies to modifications of stipulated child custody arrangements in effect for a significant period of time. The burden of proving a substantial change in circumstances is on the moving parent.

III. THE NEXUS REQUIREMENT
Trial courts are vested with broad discretion in child custody determinations. The question upon review is whether the "record shows an abuse of discretion or if controlling factual findings are clearly erroneous." Gratrix v. Gratrix, 652 P.2d 76, 80 (Alaska 1982). A trial court abuses its discretion if it "considered improper factors ..., failed to consider statutorily mandated factors, or ... too much weight was assigned to some factors." Starkweather v. Curritt, 636 P.2d 1181, 1182-1183 (Alaska 1981).
When a court determines the best interests of the child under the changed circumstances doctrine, the scope of judicial inquiry is limited to facts directly affecting the child's well-being.[3] We have often endorsed the requirement that there be a nexus between the conduct of the parent relied on by the court and the parent-child relationship.
For example, that a mother is living with another man in an adulterous relationship does not justify denying her custody absent any indication of adverse effects on the child. Bonjour v. Bonjour, 566 P.2d 667 (Alaska 1977). Nor does bearing children out of wedlock or instability in relationships warrant a custody change where the parent's conduct does not adversely affect the child or the mother's parenting abilities. Craig v. McBride, 639 P.2d 303, 306 (Alaska 1982). Even the mental health of the custodial parent is "relevant only insofar as it has or can be expected to negatively affect the child." Morel v. Morel, 647 P.2d 605, 608 (Alaska 1982) (citations omitted).
Father maintained in the superior court and on appeal that this case does not involve sexual preference discrimination issues. This is not supported by the record, which is replete with evidence that Mother is a lesbian.[4]
The trial court found that there had been substantial changes in circumstances justifying a custody modification. Specifically, the court entered Finding of Fact 51, which states:
There has been a change of circumstances in the parties' lives since the original decree sufficient to warrant a review and change of custody to plaintiff as follows:
(a) At the time of the earlier decree [the child] was unborn and custody in plaintiff was physically impossible;
(b) A child has an overriding need to be with its mother during the first days and months of its life, if possible, and that phase of [the child's] life has passed;[5]

*879 (c) Plaintiff and [his current wife] have become at least equal caretakers of [the child] and defendant has relinquished that authority in [the child's] life to them;
(d) Defendant has since the original decree significantly changed personally including a choice to live a homosexual lifestyle;
(e) Defendant has moved her residence to Seattle, Washington, and has left her profession, perhaps permanently, so that [the child's] household, community and contact with his father and most appropriate male role model will be significantly altered unless custody is changed to plaintiff;
(f) Defendant has demonstrated an inability at times to cope with child rearing without significant support from plaintiff or others;
(g) Defendant has actively interfered with the development of an open, frequent and loving relationship between plaintiff and their son... .
Finding of Fact 51(d) reflects the taint apparent throughout the record.
In marked contrast to the wealth of testimony that Mother is a lesbian, there is no suggestion that this has or is likely to affect the child adversely.[6] The record contains evidence showing that the child's development to date has been excellent, that Mother has not neglected him, and that there is no increased likelihood that a male child raised by a lesbian would be homosexual. Simply put, it is impermissible to rely on any real or imagined social stigma attaching to Mother's status as a lesbian. Cf. Palmore v. Sidoti, ___ U.S. ___, 104 S.Ct. 1879, 80 L.Ed.2d 421 (1984).
Since the lower court's findings were impermissibly tainted by reliance in part on the fact that Mother is a lesbian, we remand this case to the superior court to consider whether there has been a substantial change in circumstances justifying a custody modification.[7] Consideration of a parent's conduct is appropriate only when the evidence supports a finding that a parent's conduct has or reasonably will have an adverse impact on the child and his best interests. See Horutz v. Horutz, 560 P.2d 397, 401-402 (Alaska 1977).

IV. VALIDITY OF THE "GAG" ORDER
Mother challenges the constitutional validity of a pretrial protective order entered by Judge Ripley, set forth in full in the margin.[8] Resolution of this issue requires *880 balancing competing interests of free speech with the possible adverse effect on the child of publicity of the details of this action.
The Alaska Constitution guarantees to every person the right to speak freely.[9] However, a court may close child custody proceedings if closure is in the best interests of the child.[10]
Compelling justification is required to uphold an order infringing the right of free speech.
As we have noted, where such fundamental rights as freedom of speech and association are involved, only compelling government interests will justify their encroachment. Mickens v. City of Kodiak, 640 P.2d 818 (Alaska 1982); Messerli v. State, 626 P.2d 81 (Alaska 1981). An essential aspect of this test is an inquiry into whether less restrictive alternatives will adequately protect those interests.
Vogler v. Miller, 651 P.2d 1, 5 (Alaska 1982). Since the state clearly has a compelling interest in protecting the child, the question before us is whether a less restrictive protective order would adequately shield him from the adverse effects of undue publicity. We conclude that the order is overbroad.
A protective order arises from and must be tailored to fit the circumstances of a particular case; it is difficult to establish a general test for constitutional validity. However, an order which goes beyond assuring confidentiality of the file and anonymity of the parties must be justified by compelling circumstances and drawn as narrowly as possible to protect against particular evils. Instead, Paragraphs 3 and 4 create a blanket prohibition against all communication with persons not specified in the order, and expressly limit the scope of permissible communication with the persons specified.
As Mother correctly points out, Paragraph 3 prevented both parents from discussing the case with spouses or partners except in their capacity as potential witnesses, and then only as necessary to further the presentation of the case. It apparently precluded Mother and Father from seeking professional counseling about the proceedings had they so desired. It prevented counsel from obtaining assistance from or providing assistance to other lawyers handling similar cases.
Paragraph 3 could have been more narrowly drawn, allowing a wider circle of communication, without endangering the best interests of the child. Absent careful scrutiny by the trial court revealing compelling justification for such a broad infringement on freedom of expression, the order cannot withstand constitutional scrutiny.
The judgment of the superior court is REVERSED and the case REMANDED for further proceedings consistent with this opinion. Paragraphs 3 and 4 of the protective order of August 8, 1983 are VACATED.
BURKE, Justice, concurring in part, dissenting in part.
I agree that the trial court's "gag" order violated article I, section 5 of the Alaska Constitution. I disagree, however, with that part of the majority opinion holding that the trial court's decision to modify custody was fatally flawed by references *881 to the matter of Mother's sexual orientation.
Those references, I believe, are taken entirely out of context. After explaining its decision on the record, the trial court entered formal findings of fact. Together, the court's explanation and findings reflect a careful analysis of the difficult issue to be decided, and a thorough understanding of the proper weight to be given to the matter of Mother's sexual preference. I would affirm the court's custody determination.
NOTES
[1]  AS 25.20.060(a) provides in pertinent part that:

If there is a dispute over child custody, either parent may petition the superior court for resolution of the matter under AS 25.20.060  25.20.130. The court shall award custody on the basis of the best interests of the child... .
[2]  AS 25.20.110 provides in pertinent part that:

An award of custody of a child ... may be modified if the court determines that a change in circumstances requires the modification of the award and the modification is in the best interests of the child... .
[3]  AS 25.24.150(d) provides that:

In awarding custody the court may consider only those facts that directly affect the well-being of the child.
[4]  Sixteen of the 22 witnesses who testified discussed homosexuality. Sixteen of the 51 Findings of Fact and 2 of the 13 Conclusions of Law refer to Mother's lesbianism.
[5]  [We note that Finding of Fact 51(b) unfortunately smacks of the tender years doctrine, expressly rejected in this state. Faro v. Faro, 579 P.2d 1377 (Alaska 1978); Johnson v. Johnson, 564 P.2d 71 (Alaska 1977), cert. denied, 434 U.S. 1048, 98 S.Ct. 896, 54 L.Ed.2d 800 (1978).]
[6]  The only nexus found by the superior court between Mother's sexual preference and a possible adverse effect on the child related to the likely duration of Mother's current relationship. The superior court found that this relationship might be less stable and longlasting than Father's most recent marriage. However, this was essentially conjecture by the court, since there was no evidence Mother's relationship was not committed. Instead, the court relied on its own unsupported opinion that homosexual relationships are unstable and usually of short duration.
[7]  On remand, the trial court may consider the time the child has spent with either parent while this appeal was pending. Craig v. McBride, 639 P.2d 303, 307 (Alaska 1982). The burden of proving changed circumstances of course remains with Father as the moving parent. The additional time spent by the child with Father during these proceedings should not by itself be considered a change of circumstances, but should only be considered as it bears on the best interest of the child.
[8]  The protective order provides that:

Based upon the July 14, 1983 hearing before Master Andrew M. Brown, his recommendations and any objections thereto, is hereby ordered that:
1. This Court file be sealed and only opened by Court personnel directly connected to these proceedings or by counsel of records [sic].
2. All hearings in this case are closed.
3. The communication of any information related to this case is prohibited except as follows:
(a) Communication between or among any of the following:
Attorneys of Record, their employees, the parties, expert witnesses employed by the parties or their counsel and investigators.
(b) Communication with witnesses or potential witnesses and then only as necessary to further the presentation of the parties' case in court and the child's interests.
(c) Communication with other experts as necessary to further the presentation of the parties['] case in Court and the child's interests and then only if the names of all persons involved including witnesses are omitted or in the case of writings are obliterated.
4. All persons to whom communications are made pursuant to ¶ 3(a)-(c) shall be provided a copy of this order and admonished by counsel of this Court's directive as to confidentiality. (emphasis in original).
[9]  Alaska Const. art. I, § 5, provides that:

Every person may freely speak, write, and publish on all subjects, being responsible for the abuse of that right.
[10]  AS 25.20.120 provides that:

At any stage of a proceeding involving custody of a child the court may, if it is in the best interests of the child, close the proceeding to the public or order the court records closed to the public temporarily or permanently. The court may modify or vacate an order under this section at any time.
