Yevamos4: 11
אַרְבָּעָה אַחִין נְשׂוּאִין אַרְבַּע נָשִׁים, וָמֵתוּ — אִם רָצָה הַגָּדוֹל שֶׁבָּהֶם לְיַבֵּם אֶת כֻּלָּן הָרְשׁוּת בְּיָדוֹ.  מִי שֶׁהָיָה נָשׂוּי לִשְׁתֵּי נָשִׁים, וָמֵת — בִּיאָתָהּ אוֹ חֲלִיצָתָהּ שֶׁל אַחַת מֵהֶן פוֹטֶרֶת צָרָתָהּ. הָיְתָה אַחַת כְּשֵׁרָה, וְאַחַת פְּסוּלָה, אִם הָיָה חוֹלֵץ — חוֹלֵץ לַפְּסוּלָה. וְאִם הָיָה מְיַבֵּם — מְיַבֵּם לַכְּשֵׁרָה.
[If] four brothers were married to four women and [then] died, if the eldest of them wished to perform yibum with all of them, he may do so.  [If] someone was married to two women and [then] died, conjugal relations or chalitzah with one of them releases her co-wife. [If] one was qualified and one was disqualified, if he is [going] to perform chalitzah, he should do so with the disqualified one; but if he is [going] to perform yibum, he may do so with the qualified one.
Yevamos4: 12
הַמַּחֲזִיר גְּרוּשָׁתוֹ, וְהַנּוֹשֵׂא חֲלוּצָתוֹ, וְהַנּוֹשֵׂא קְרוֹבַת חֲלוּצָתוֹ — יוֹצִיא, וְהַוָּלָד מַמְזֵר; דִּבְרֵי רַבִּי עֲקִיבָא. וַחֲכָמִים אוֹמְרִים: אֵין הַוָּלָד מַמְזֵר. וּמוֹדִים בְּנוֹשֵׂא קְרוֹבַת גְּרוּשָׁתוֹ שֶׁהַוָּלָד מַמְזֵר.
[If] one remarries his divorced wife, or he marries his chalutzah, or the relative of his chalutzah, he must send her away, and the child [of that union] is a mamzer; [these are] the words of R' Akiva. The Sages, however, say: The child is not a mamzer. But they admit that if he marries the relative of his divorced wife, that the child is a mamzer.