(a) Unless otherwise resolved by agreement of the parents under section 9-201 or unless manifestly harmful to the child, the court shall allocate custodial responsibility so that the proportion of custodial time the child spends with each parent approximates the proportion of time each parent spent performing caretaking functions for the child prior to the parents' separation or, if the parents never lived together, before the filing of the action, except to the extent required under section 9-209 or necessary to achieve any of the following objectives:
(1) To permit the child to have a relationship with each parent who has performed a reasonable share of parenting functions;
(2) To accommodate the firm and reasonable preferences of a child who is fourteen years of age or older, and with regard to a child under fourteen years of age, but sufficiently matured that he or she can intelligently express a voluntary preference for one parent, to give that preference such weight as circumstances warrant;
(3) To keep siblings together when the court finds that doing so is necessary to their welfare;
(4) To protect the child's welfare when, under an otherwise appropriate allocation, the child would be harmed because of a gross disparity in the quality of the emotional attachments between each parent and the child or in each parent's demonstrated ability or availability to meet a child's needs;
(5) To take into account any prior agreement of the parents that, under the circumstances as a whole including the reasonable expectations of the parents in the interest of the child, would be appropriate to consider;
(6) To avoid an allocation of custodial responsibility that would be extremely impractical or that would interfere substantially with the child's need for stability in light of economic, physical or other circumstances, including the distance between the parents' residences, the cost and difficulty of transporting the child, the parents' and child's daily schedules, and the ability of the parents to cooperate in the arrangement;
(7) To apply the principles set forth in 9-403(d) of this article if one parent relocates or proposes to relocate at a distance that will impair the ability of a parent to exercise the amount of custodial responsibility that would otherwise be ordered under this section; and
(8) To consider the stage of a child's development.
(b) In determining the proportion of caretaking functions each parent previously performed for the child under subsection (a) of this section, the court shall not consider the divisions of functions arising from temporary arrangements after separation, whether those arrangements are consensual or by court order. The court may take into account information relating to the temporary arrangements in determining other issues under this section.
(c) If the court is unable to allocate custodial responsibility under subsection (a) of this section because the allocation under that subsection would be manifestly harmful to the child, or because there is no history of past performance of caretaking functions, as in the case of a newborn, or because the history does not establish a pattern of caretaking sufficiently dispositive of the issues of the case, the court shall allocate custodial responsibility based on the child's best interest, taking into account the factors in considerations that are set forth in this section and in section two hundred nine and 9-403(d) of this article and preserving to the extent possible this section's priority on the share of past caretaking functions each parent performed.
(d) In determining how to schedule the custodial time allocated to each parent, the court shall take account of the economic, physical and other practical circumstances such as those listed in subdivision (6), subsection (a) of this section.